Run automator workflow with keyboard shortcuts
In the last post we demonstrated how to automate a task using AppleScript and the Fake scriptable web browser. Often, I use Automator included on every Mac to perform such tasks. To activate them, we bind them to a keyboard shortcut in the given application. The example we will use today is to press a keyboard shortcut to load the remote content of an email in Mail.app (you have of course turned offloading all remote content in emails by unselecting Load remote content in messages in the Viewing part of Mail.app Preferences).
Create the Automator workflow
We start by creating the Automator workflow:
- Start Automator and select New Document.
- Choose the type of workflow to be Services.
- Choose that service receives no input in Mail.app.
- Open Mail.app and open an email with (unloaded) remote content.
- In Automator, press the Record button.
- In Mail.app, press the Load Remote Content button.
- In Automator, terminate recording.
- Save the service workflow with the name Load Remote Content.
You should now be able to run this from the Automator to test it (try it by selecting a message with remote content, where the remote content is not loaded). Before you test it, be sure that you have given Automator (and Mail.app) access to control your computer. You do that in System Preferences (Security & Privacy → Privacy → Accessibility).
The keyboard shortcut
You should check that the Service you have created is visible in the Mail → Services menu (the Load Remote Content menu is there). If it is there, let us create the keyboard shortcut for it. Open System Preferences and select Keyboard → Shortcut. In App Shortcut, add a new one with the plus (+) button. Choose Mail.app for the Application, and in the menu title, type exactly as it was written above: Load Remote Content. Choose your Keyboard Shortcut (I used Shift-Control-Cmd-I) and press Add.
Now, whenever you read a message with (unloaded) remote content, pressing the keyboard shortcut will load the content in the message.