February 10, 2010

Creating a Service to Select a Menu Item in your Application

In Snow Leopard, using Snow Leopard and Applescript/Automator, you can create a global keyboard shortcut to do just about anything you can imagine. As an example, this is how you would create a Service to select a specific menu item inside of an application such as Accordance. This will allow you to assign a global keyboard command to it via the Keyboard panel of the System Preferences:

1. Open up Automator

2. Choose a template: Service

3. At the top of the right panel, change the popup menu from "Service receives selected text" to "Service receives no input"

4. Leave "Replaces selected text" unchecked.

5. In the "Actions" panes to the left, find "Run Applescript" and drag it over to your workflow.

6. Replace the line that says (* Your script goes here *) with the following 6 lines:

tell application "Accordance" to activate

tell application "System Events"

tell process "Accord"

click menu item 1 of menu 1 of menu item "Favorites" of menu 1 of menu bar item "Amplify" of menu bar 1

end tell

end tell

7. Save it via menu File/Save and name it something like "Accordance Amplify Favorite"

8. Quit Automator

9. Go to Keyboard pane of the System Preferences and assign it a global keyboard combo.

10. Test

This Service will bring Accordance to the front, and then select the first item under the Favorites submenu under the Amplify menu.

Note: The part in the Applescript line that reads click menu item 1 is telling it to select the first Favorited item in the list. You can reorder the Favorites in the Library Window in Accordance. (Look for the submenu at the bottom of the module list.) You can also specify a Favorite by name... just change click menu item 1 to something like: click menu item "MyFavoriteWorkspace" replacing the 1 with the name of the workspace inside of quotes.

1 comment:

Unknown said...

Sorry, Joe. But I followed your instructions to create the Services item, and when I tried to run it, I got a message from the system that there was an error in the work flow. Also, the last 2 or 3 steps in your instructions assumed too much knowledge, leaving out specifics. I really appreciate your efforts for us users, but you have to assume no prior knowledge when you write instructions.