How to create keyboard shortcuts to launch apps in macOS using Automator
While macOS allows users to create their own keyboard shortcuts to perform functions in apps, there isn't a built-in way to launch the apps themselves using a similar maneuver. AppleInsider shows you one way to create app-launching keyboard shortcuts, using the included Automator utility.
Apple included a fairly simple way to create custom keyboard shortcuts within System Preferences, which can easily be used to produce shortcut combinations for app functions that do not already have one defined. While the Shortcuts settings also enables various other system functions to run, the extensive list simply doesn't have an option to run a user-defined app.
This doesn't mean it is impossible to launch an app by creating a shortcut, but handily it is possible to trigger something else that in turn can load an app. In this case, we will be creating a keyboard shortcut to trigger an Automator-produced event, which will open up the selected app.
Open Automator. It can be found in the Applications folder, accessible by selecting Go then Applications in the Finder menu or by using the keyboard shortcut Shift Command A.
If this is your first time in Automator, you should be presented by an initial window offering to start a new document, though if it doesn't appear, select File then New in the menu to start from scratch. At this point, select Service then the Choose button.
In the top section starting "Service receives," set the dropdown box to "no input," and check to make sure the second dropdown is set to "any application."
Click Actions in the top-right corner, scroll down the list of actions in the second column to find Launch Application, and drag it into the main workflow box to the right. This will add a new Launch Application section to the workflow box.
Select the application you want to open from the shortcut using the Launch Application dropdown box.
Select File then Save in the menu, enter an appropriate name for the command, and click Save. Close Automator.
Select Services in the left-hand column, then scroll down to the service with the same name as the command created in Automator. If the side tick isn't visible, click it before clicking the command, then click the Add Shortcut button that appears.
At this point, select the key combination you want to use to open the selected application and press the buttons at the same time. If macOS accepts the combination, it will then show the keyboard combination in the listing.
Close the System Preferences window and test out the keyboard command.
Also, be aware of setting a keyboard shortcut that may duplicate one that is already in use by another system function or app, in case they conflict with each other or fail to perform an action at all. The last thing you want is to go to the trouble of setting up a key combination that ultimately doesn't do what you want.
Apple included a fairly simple way to create custom keyboard shortcuts within System Preferences, which can easily be used to produce shortcut combinations for app functions that do not already have one defined. While the Shortcuts settings also enables various other system functions to run, the extensive list simply doesn't have an option to run a user-defined app.
This doesn't mean it is impossible to launch an app by creating a shortcut, but handily it is possible to trigger something else that in turn can load an app. In this case, we will be creating a keyboard shortcut to trigger an Automator-produced event, which will open up the selected app.
Using Automator
First, we need to create an Automator service that, when prompted, will open our selected application.Open Automator. It can be found in the Applications folder, accessible by selecting Go then Applications in the Finder menu or by using the keyboard shortcut Shift Command A.
If this is your first time in Automator, you should be presented by an initial window offering to start a new document, though if it doesn't appear, select File then New in the menu to start from scratch. At this point, select Service then the Choose button.
In the top section starting "Service receives," set the dropdown box to "no input," and check to make sure the second dropdown is set to "any application."
Click Actions in the top-right corner, scroll down the list of actions in the second column to find Launch Application, and drag it into the main workflow box to the right. This will add a new Launch Application section to the workflow box.
Select the application you want to open from the shortcut using the Launch Application dropdown box.
Select File then Save in the menu, enter an appropriate name for the command, and click Save. Close Automator.
Creating the shortcut
Select the Apple logo in the Menu, and select System Preferences then the Keyboard icon in the second row. Select the Shortcuts tab, which should be in the middle of the five tabs near the top of the window.Select Services in the left-hand column, then scroll down to the service with the same name as the command created in Automator. If the side tick isn't visible, click it before clicking the command, then click the Add Shortcut button that appears.
At this point, select the key combination you want to use to open the selected application and press the buttons at the same time. If macOS accepts the combination, it will then show the keyboard combination in the listing.
Close the System Preferences window and test out the keyboard command.
Further Thoughts
While this tip largely centers around opening an app, the same principles can be used to create keyboard shortcuts to do a multitude of tasks. If a sequence of events is set up in Automator and saved as a service, it can be assigned a keyboard shortcut, and could be used to perform multi-stage tasks with a single collective key press.Also, be aware of setting a keyboard shortcut that may duplicate one that is already in use by another system function or app, in case they conflict with each other or fail to perform an action at all. The last thing you want is to go to the trouble of setting up a key combination that ultimately doesn't do what you want.
Comments
Years ago, when Apple introduced OX X, Gruber provided how to articles to help noobs get comfortable with the new OS... they were invaluable! Lately tho, Gruber has become less technical and more political...
Now, I appreciate these How To articles on AI... Keep 'em coming!
IMO, the popular fast-evolving Swift language is a goldmine waiting to be mined for how to articles.
Automator hasn't been upgraded recently & the web site is not an Apple site -- it belongs to the Automator Guru who used to work for Apple.
Oddly, the Provide Automator Feedback still goes thru the Apple Site
AppleScript was one of the great Apple inventions.
BTW, there are a lot of macOS applications included with macOS that weren't updated with the 2017 release of High Sierra. There are even more when you look at the included apps that only have a 2017 date despite macOS point updates in 2018. Not updating an app just update an app doesn't mean it's being deprecated. What features in Automator are you looking for that should've been added because of changes between Sierra and High Sierra?
FWIW, Here's a Swift Playground, that:
That' a pretty old page -- June 30, 2015...
He was using Swift 1.2 -- that's baby Swift (notice the println) -- were on Swift 4.x now and open sourced.
That is not a bash script! The shebang in line 1 identifies it as a Swift script.
You could call a bash script which then invoked the Swift script -- but that's just busy work.
The reason I think this is so important is this:
If you've ever done a server-side install of an app, even simple apps require downloads and installs of multiple supporter apps and packages -- each with their own prerequisite downloads and installs. This is a very long, fiddly, cryptic, error-prone, interactive process... if you're on your toes, and know enough about CLI scripts you can:
Kinda' reminds one of a Windows install in the late 1990s...
Swift offers the potential of a great improvement as the Swift scripts:
But if you need to install an app that doesn't exist on your computer that involves a series of processes. that:
- download some data from the server that is used as input to another process that
- downloads some other data from the sever that installs multiple pieces (executable apps, command and data files) all over your computer
- rinse and repeat many times
There are low-level constructs built into every Unix OS system called shell scripts and shell commands that allow the OS system to install and update itself. macOS is a Unix OS.When you install or upgrade macOS it runs a package that contains many low-level constructs, data, and processes -- it's a high-level package that runs a lot of low-level stuff under the covers. The people who wrote that package have meticulously packaged the low-level stuff so you don't need to involve yourself or baby-sit the long, complicated process.
Many developers write apps that run in the Cloud and are accessible from a web browser or from an app on your computer, tablet, TV Controller, smart speaker, smart phone, watch, etc. The web browser or device app provides a user interface to the Cloud app which does the heavy lifting.
One of the Cloud apps that is becoming popular is IBM's Watson, an AI app (and much more). You may have seen recent TV adds for Watson -- recommending maintenance for an elevator or an airplane.
A developer who wants to access Watson, goes through a series of installation processes on IBM's servers before he can even access Watson from a browser or device app.
One of the simple apps that a developer will, likely, install is IBM's web server app called Kitura -- because Kitura provides easy access to the Watson backend
Here's the IBM web page on Kitura:
.
and here's the simple install process * for you to perform:
Your 3 minutes start now! Let us know how it turns out!
* there's no simple install process accessible from Spotlight, but there could be -- that's what I'm blathering about!
Automator is a scripting application with a GUI.
The Further Thoughts paragraph suggests using the scripting technique shown to write more complex tasks.
Thread comments #1 and #3 opened up a more general discussion of scripting (good or bad) with Automator vs it's predecessor AppleScript. Most of the ensuing posts on this thread were discussing scripting
In post #8 I said: I would like to see Swift as an option for a Automator Shell Script.
I thought it odd that Automator supports shell scripts written in Perl, Python and Ruby -- and not support Swift shell scripts -- as Swift was developed by Apple and is a very popular language. I thought the ability to write Swift Shell Scripts would enhance appeal of Automator.
FWIW, Most Apple apps and quit a few 3rd-party apps are written so that you modify the way an app works to customize output (they have a built-in scripting dictionary/library).
Also an Automator script can have multiple segments -- the one the author showed just launched an app with a kb shortcut... It was left to the imagination of the reader to consider the possibilities of writing scripts to automate multi-stage tasks.
Then you post:
IMO, this was OT to the subject of the article and the discussion that followed: automating tasks with scripting.
When I replied: Spotlight works for apps that already exist on your computer... and gave examples...
You accused me of blathering and suggest that I am on the wrong thread.
Maybe I am -- I thought it was a discussion of automating tasks with scripts.