Jump to content

How do I click on menu bar actions with Alfred?


Recommended Posts

Let's say I have a menu bar app on my Mac, like Alfred (just as an example). How can I create an Alfred keyword to click on the "Check for Updates..." item?

 

I assume this would be best achieved by using AppleScript? And if so, how would I write the code?

Link to comment

IF you didn't already know, Alfred has an option to check for updates, either "Updates" or "Pre-Releases" in the update tab.

As far as other apps, if the app does not have an automatic update checker built in, it MAY have an Apple Script dictionary entry to check for regular updates.

Another option is to use GUI Scripting, but you may need to use a UI Browser screen reader to find the actual item depending on the app: http://stackoverflow.com/questions/16492839/applescript-on-clicking-menu-bar-item-via-gui-script

Link to comment

Short answer: http://www.packal.org/workflow/menu-bar-search

 

Long answer:

1. Use the menudump command in the above workflow to dump the menu structure of the app you're targeting (--help for details)

2. Use the output to determine the Applescript line to target the menu item, e.g.,

 

tell menu item "Check For Updates…" of menu "iTerm2" of menu bar item "iTerm2" of menu bar 1

    if (it exists) then perform action \"AXPress\"

end tell 
 
You can look at the execute.scpt file in the above workflow for more details.
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...