AppleScript help needed...

Discussion in 'Mac Programming' started by jbarley, May 24, 2018.

  1. jbarley, May 24, 2018
    Last edited: May 24, 2018

    jbarley macrumors 68040

    jbarley

    Joined:
    Jul 1, 2006
    Location:
    Vancouver Island
    #1
    Hope this is the right forum.:)
    My problem is I want to use an older version of "EtreCheck" on my older MacPro hardware, and each time I fire it up I get a window offering me to update.
    I've contacted the author and he tells me as long as I'm using this earlier version I'm stuck with the window.
    I'm sure someone with the skills could whip up an AppleScript to launch EtreCheck and supply the necessary action to close this annoying popup.
    Is this possible? Any help would be appreciated.

    Screen Shot 2018-05-24 at 8.15.29 AM.png
     
  2. Rick Corbett macrumors newbie

    Rick Corbett

    Joined:
    Apr 27, 2018
    Location:
    South-west UK
    #2
    Hmm... no replies so far.

    I'm just getting into AppleScript but it seems like it should be fairly simple. (Probably famous last words.)

    I think the steps are:

    1. Work out the attributes (names) of the Update available window and the No, skip this update button (using something like the UIElementInspector).

    2. Create a user interface script using AppleScript, probably something like:
    Code:
    tell application "EtreCheck"
    activate
        tell process "EtreCheck"
            tell window 1
                click (first button where its accessibility description = "No, skip this update")
            end tell
    end tell
    3. Save the script.

    4. Enable User interface scripting for the script.

    The script would then launch EtreCheck, wait for the Update Available dialog and click the required button.

    That should be all you need but I can't add any more info unless you post the version of EtreCheck that you're using.

    Hope this helps...
     
  3. Red Menace macrumors 6502

    Red Menace

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #3
    Etrecheck doesn't have a scripting dictionary, so you would need to use System Events to script the user interface.
     
  4. Rick Corbett macrumors newbie

    Rick Corbett

    Joined:
    Apr 27, 2018
    Location:
    South-west UK
    #4
    Many thanks.
     
  5. Rick Corbett macrumors newbie

    Rick Corbett

    Joined:
    Apr 27, 2018
    Location:
    South-west UK
    #5
    I got UIElementInspector working then downloaded a version of EtreCheck. It's obviously not the same version as the OP but enough for me to learn the principles of creating a user interface script.

    Following examples elsewhere and checking the element names with UIElementInspector, I came up with this:
    Code:
    activate application "EtreCheck"
    tell application "System Events"
        tell process "EtreCheck"
            click button "Skip" of window "Update Available"
        end tell
    end tell
    upload_2018-6-4_17-40-2.png

    It seemed to work once but now I think I must have imagined this because it fails every time with:

    error "System Events got an error: Can’t get window \"Update Available\" of process \"EtreCheck\"." number -1728 from window "Update Available" of process "EtreCheck"

    I've tried numerous variations but no joy because I don't understand why the script can't get the window.

    I'm not too disheartened 'cos this is my very first AppleScript but I would like to know if I've made a very basic error. Any help would be greatly appreciated.
     
  6. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    Location:
    Sailing beyond the sunset
    #6
    If you run EtreCheck by itself, not from the script, does it always present the "Update Available" window?

    I ask because the way I interpret "Skip"is that it would ask once, when an update becomes available, and if you tell it "Skip", it won't ask again until the subsequent update becomes available. This is how other programs I use act with self-updates and "Skip". If EtreCheck is using that logic, then there won't be an "Update Available" window, so the script will fail. (This wouldn't explain why the OP is getting asked every time, but that may be a distinct problem.)

    You can catch and handle errors in AppleScript using the try ... on error ... end control structure. See:
    https://developer.apple.com/library...riptLangGuide/reference/ASLR_error_xmpls.html

    You might also be able to check for a button "Skip" using an if statement, but I don't recall if UI Scripting can do that or not, and I'm not in a position to test it myself right now.
     
  7. Rick Corbett macrumors newbie

    Rick Corbett

    Joined:
    Apr 27, 2018
    Location:
    South-west UK
    #7
    Yes, EtreCheck asks every time it runs.
    I'll have a look at both. Thank you.
     
  8. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #8
    I've not tried this myself, but perhaps you could approach the problem another way? If you were to open the app as a package (ctrl-click it and select "Show Package Contents) then there should be an info.plst file.

    My *hunch* would be that if you hunt for a version number in there and change it to something very large then you'll stop getting the dialog. For example, if it says:

    Code:
        <key>CFBundleShortVersionString</key>
        <string>1</string>
    
    ...then change it to...

    Code:
        <key>CFBundleShortVersionString</key>
        <string>1000</string>
    
    Make sure you use a text editor e.g. BBEdit/TextWrangler, not Word or anything like that!

    I'm guessing that the app compares its version number to some kind of record online (web service, rss or something) and if your version is lower than the record online then it tries to update. If you pretend to have a much higher version then it may be fooled into not asking you to update.

    Make sure you have a backup of your app in case Something Bad happens.

    Interested to know if that works!
     

Share This Page