How to Launch Any App with a Keyboard Shortcut

How to Launch Any App with a Keyboard Shortcut

Tutorial Details
  • Topics: Keyboard Shortcuts, Automator, Services
  • Difficulty: Intermediate
  • Estimated Completion Time: 15 Minutes

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.


The Rules

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!

Tweetbot
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?

System Preferences
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.

Automator
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.”

Automator
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.

Automator
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.

Automator
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.

System Preferences
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.

Josh Johnson is secondfret on Graphicriver
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://macintoshprograms.com joe

    all my favorite apps has on the dock, so i don’t need it now,
    i’ll be wait for next automator tutorial :)

  • Fred

    Spotlight is easier: Command/Spacebar then start typing the name of the app. When you see it populate (usually the first item in the list but if it isn’t, use the arrow keys to move down the list to the app you want), touch Return and the app launches. I use this all the time and never have to reach for the mouse and then mouse over the Dock to find the app I’m looking for. I’ve used app launching utilities before, but with Spotlight you never have to remember what keyboard shortcut you assigned to your apps.

    • http://mac.tutsplus.com Josh Johnson
      Author

      Yep, I use Alfred to launch apps. However, this was in response to a real question from someone who knew all about Spotlight and other app launchers and still wanted a dedicated app shortcut without third party software.

  • John Davis

    Use Alfred or Quicksilver.

    It’s much easier.

    • http://mac.tutsplus.com Josh Johnson
      Author

      “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.” – Not my rules, just my solution ;)

  • Martin

    I just use Better Touch Tool. I can set up my trackpad and magic mouse actions and global shortcuts. And its basically a service running in background…

  • http://vinodhanv.wordpress.com Vinodhan

    Really informative. I would also say Alfred can be used. Also BetterTouchTool can be used. Its in beta but Its so handy. You can define global shortcut keys or app specific (Chrome). Its so awesome too…

  • Marco

    Great tut,
    I have one question, is possible to use the F13 to F19 keys with this?
    I’ve tried but didn’t work, is there any workaround?

    • http://mac.tutsplus.com Josh Johnson
      Author

      Not sure why those keys wouldn’t work… but I think it wants something with a modifier key.

  • http://www.facebook.com/tijl.willemsens Tijl Willemsens

    I tried it but doesn’t work.

    • .sh

      didn’t work for me either…any tips from the OP?

      • .sh

        also please let us know how to use applescript for this same functionality. thanks

  • too easy

    As great as you think your solution, there is something much simpler: map a command to the application name in the recent submenu of the apple menu. (assuming that if you want a keyboard shortcut for this application it will be in the top 20 at all times [you can increase the number of recent items this menu shows])

  • Kitten

    Tried it, but the Application I saved didn’t show up in the service list. Too bad, I was really hoping this would work. What’s the best 3rd party app for a text shortcut (not something like Alfred that involves typing the name in). Thanks in advance

  • Kevster

    To get this to work you need to go into System Preferences / Keyboard / Keyboard tab, then check the box called “Use all F1, F2 keys as standard function keys”

  • TantoGlamour

    Yes, don´t work fine. If you have inactive de button: Keyboard-Use all F1, F2, etc. don´t work in the Finder, works un other apps. If you have active de button: Keyboard-Use all F1, F2, etc works on all apps but you lose the volume/bright control keys. It´s no good.

  • Peter

    Saved me a lot of time. How to donate? :)

  • Nshah

    how about use QuickSilver? CTRL+Space type application name and it opens your application…

  • Azoic

    Thanks for the tut. A useful concept, but:

    This works only when another application is active (like system preferences, preview, etc). However, if Finder is active (which it is by default when no application is active) the shortcut does not work and the application it is assigned to does not launch.

    This is really annoying because mostly I want to launch Safari from a clean desktop and to require an application to be active before the shortcut works defeats the purpose by requiring me to open/activate some other application first.

    I tried to modify the Automator file but don’t really know what I’m doing. If you could reply with a fix that would be appreciated as otherwise this solution isn’t really a viable one.

    Cheers!

    (P.S. I’m on Lion)

  • gerram

    Nice tutorial. But I would want to append a second part. Method from above works only if your app (what you chose in Automator) is launched. In other case you will get nothing. For right work our method you have to make some small additional steps:

    1. System Preferences -> Keyboard -> Application Shortcuts -> All Applications

    add new line with properties: Application: All Applications; Menu Title: Launch Tweetbot; Keyboard Shortcut: Option-Shift-Command-T

    and you Service will appear at every app into Services menu and will work as you want -> from hot and from cold start