Today we’re going to rise up and face a challenge that was posed to me recently: how do I assign a keyboard shortcut to launch an app? There’s no obvious built-in functionality for achieving this, but with a little ingenuity we can pull it off with very little effort. Read on to find out how.
As you’re no doubt aware, there are lots of third party Mac apps that we could use to pull this off (such as Apptivate). That’s the great thing about being a Mac user, the developer community is always eager to step forward and fill in any gaps in functionality.
The person in question only wanted a single app shortcut and couldn’t justify purchasing, downloading and/or installing an app just to make this happen.
That being said, the original challenge, as it was given to me, came with some stipulations. First, no third party utilities were to be used. The person in question only wanted a single app shortcut and couldn’t justify purchasing, downloading and/or installing an app just to make this happen.
Further, no complex scripting was to be used. If you keep up on my articles, you know that I’m an AppleScript nerd and would normally turn there right away in this situation. Unfortunately, this person was not familiar or comfortable with scripting, so that option is out too!
We’re going to figure out how to launch Tweebot with a keyboard shortcut.
Admit Defeat? Never!
Admittedly, this sounded like a nearly impossible feat to pull off. The functionality simply isn’t in OS X and if I wasn’t allowed to turn to AppleScript, what else could I do?
In less than two minutes flat, I had a working solution
Fortunately, I love a good puzzle. In less than two minutes flat, I had a working solution, thanks to the other major automation assistant that ships with OS X: Automator.
Services to the Rescue
I knew that Automator held the key to performing AppleScript-like functionality without the hassle of learning to code. But an Automator action to launch an app wouldn’t do me any good on its own, I would still need a way to tie the action to a keyboard shortcut. But how?
The Keyboard Shortcuts pane does us no good.
If we take a look at the “Keyboard Shortcuts” pane in System Preferences, we see only one section where we can add new shortcuts: “Application Shortcuts.” This doesn’t really help us in any way though, as it only serves as a way to execute a menu command in a currently open app.
All we need to do is create a custom service that launches a specific app, then give it a shortcut here.
While digging around here though, I stumbled on my answer: the Services menu. OS X allows you to assign global shortcuts to any Service. All we need to do is create a custom service that launches a specific app, then give it a shortcut here. Checkmate! Let’s see how to pull this off.
Step 1. Set Up an Automator Service
Our first step is to launch Automator and go to File > New. You should see a window pop up that gives you some options for what to create. Click on “Services” and hit the “Choose” button.
Open Automator and choose “Service”
This will launch a clean slate in Automator where we can construct our workflow. If you’ve never worked with Services in Automator, don’t worry, as with everything else in Automator, they’re super easy!
Services are contextual workflows available throughout Mac OS X. They accept text or files from the current application or the Finder.
Step 2. No Input, Any Application
Before we include any actions in our workflow, take a look at the settings near the top of the window, which govern the input for the Service that we’re building.
Normally, services are built to take input and do something with them in a given application. Ours will violate this idea though, we don’t need anything processed, we just want to launch an app. As a result, make sure you select the options “no input” and “any application.”
No Input, Any Application
Step 3. Include the Launch Application Action
Along the left side of the Automator UI, there should be a column with a bunch of actions. Run a search for “Launch Application” and drag it onto the empty canvas on the right.
Find the “Launch Application” action
Step 4. Select Your App and Save
Once you drag the “Launch Application” action onto the work area, you should see a little drop down menu that allows you to choose the specific application that you’d like to launch. I’m going to choose Tweetbot, but feel free to select anything you wish.
Drag in the “Launch Application” action and choose an app
From here, save your Service, name it and close Automator. Almost finished!
Step 5. Assign a Keyboard Shortcut
Back in System Preferences, click on the “Keyboard” pane and go to the “Keyboard Shortcuts” tab. In the left column, select “Services” and in the right column, locate and select your newly created Launch Tweetbot Service (or whatever app you went with).
From here, simply click the “Add Shortcut” button and enter in the shortcut that you’d like to use to bring up that app.
Assign a keyboard shortcut to your new Service
That’s all there is to it! Close System Preferences, go back to Finder and hit your shortcut to see if it worked. If you followed along closely, then your app should launch right away.
Finding a Unique Shortcut
The tricky Part about setting up a global shortcut is that you’re bound to find that someone else has already hard-coded that shortcut into their app. Your shortcut might work from Finder, but when you launch another app, there could be a conflict.
In my experience, a native app shortcut will override a global Services shortcut.
In my experience, a native app shortcut will override a global Services shortcut. For instance, in my example, I used Option-Shift-Command-T to launch Tweetbot. Unfortunately, Safari uses this for something else, so Tweetbot will not launch from Safari with this shortcut.
My best advice here is trial and error. Try to think of a shortcut that you don’t normally use in any application, then try it out for a few days to see if any conflicts arise.
How else could you do it?
There you have it, a quick and easy way to create a keyboard shortcut for launching a specific app: no code writing and no third party apps necessary.
Given this same challenge, how would you pull it off? Can you think of another way to do it? How about if we allow for scripting? Let us know in the comment section below.