Home / Exciting tips / Mac OS X / How to run an AppleScript with a keyboard shortcut on macOS

How to run an AppleScript with a keyboard shortcut on macOS

AppleScripts are a great way to automate a lot of things on macOS. If you really invest the time to learn how to write them, these scripts can prove to be excellent tools for managing tedious tasks. In many cases, it might be useful to run an AppleScript with a keyboard shortcut. This is possible but the process is somewhat convoluted. Here’s what you need to do.

Save AppleScript as an Application

When you double-click an AppleScript, it doesn’t run. Instead, it opens in the ScriptEditor. In order to run a script by double-clicking it, you need to save it as an app. This is really easy to do from the Save options in ScriptEditor. For our purpose, you need to save the script you want to run with a keyboard shortcut as an application. If you’re having trouble figuring out how it works, we have a detailed article on it.

Create Automator Quick Action

Open Automator and create a new Quick Action.

In the new Quick Action pane, open the ‘Workflow receives’ dropdown and set it to ‘no input’. Use the search bar and look for the ‘Launch Application’ action. Drag and drop it on to the pane on the right. Open the application dropdown and select the app you created from the script. Save the Quick Action but make sure you give it a good, sensible name.

Automator accessibility access

Open the System Preferences app and go to the Security and Privacy preference. Go to the Privacy tab and from the column on the left, select Accessibility. Click the padlock icon and enter the admin password when prompted to. Once the padlock icon is ‘unlocked’, click the plus button under the list of apps that have accessibility access, and select Automator.

Set up keyboard shortcut for Quick Action

Open System Preferences and go to the Keyboard preference. Select the Shortcuts tab and look for Services in the column on the left. Once selected, go through the pane on the right and you will find the Quick Action that you created. Double-click it, and record a keyboard shortcut to trigger it.

It is up to you to make sure the shortcut does not clash with a system or app shortcut. This admittedly leaves you with limited shortcuts that you can use and a lot of room for error. If the script is app-specific, make sure the shortcut will at least run when the relevant app is in focus even if it doesn’t run in other apps.

About excitingtips

Check Also

How to calibrate an external display on macOS

MacBooks can work with external displays but unless you’re using an Apple display you are …

Leave a Reply

Your email address will not be published. Required fields are marked *