By Jason Snell
January 24, 2017 10:28 AM PT
Automating deeper with Keyboard Maestro
I write a lot about automating repetitive computer tasks, but most of my history with automation has involved using AppleScript (and later, Automator) to control applications. The fact is, many Mac apps—and more every day!—aren’t really accessible via scripting interfaces. It’s been a black hole of automation for me, a no-go zone, but a little while ago I decided I was wasting time with some of the tasks I perform every week and I was going to dive in and take control of the situation, scripting be damned.
My tool of choice was Keyboard Maestro, which I bought to remap a bunch of keystrokes for my weird clicky keyboard. It’s an impossibly powerful utility that, among other things, lets you automate user-interface actions.
Every time I prepare to record a podcast, there’s a long chain of repetitive tasks I need to perform in order to get ready to talk. Setting up for Clockwise one morning, I noted all the tasks my morning brain has to perform before I can get on with the show:
Open Audio Hijack and make sure the right recording session is open and ready to go.
Open my IRC client and make sure I’m in the Relay FM channel and not the one for The Incomparable or the one for Accidental Tech Podcast.
Open Nicecast, my live streaming software, and make sure it’s streaming to the Relay FM server and not the one for The Incomparable.
Open four Safari tabs: advertising for the episode, the Relay content-management system, the Google Sheet we use to track the topics for Clockwise, and the tool that controls Relay’s live-streaming server.
The trick is, most of those apps aren’t particularly (if at all) scriptable. If I want to switch servers in Nicecast, there’s really only one way—open the app, open the Servers window, and click on the right radio button. Same story with the IRC client and Audio Hijack.
Fortunately, Keyboard Maestro offers a staggering number of options to automate user-interface actions. In some cases, you can literally take a screen shot of the thing you want to be clicked, drag the image into Keyboard Maestro, and tell the app to click that thing when it sees it. You can also target mouse clicks to a relative location based on the window—for example, 20 pixels down and 100 pixels right from the top-left corner.
It takes some trial and error and testing, but in the end I’ve got a system that lets me pull down a single menu bar item and perform every single one of those tasks in a few seconds. Now when I want to get ready for Clockwise, I just pull down “Get Ready for Clockwise” from the Keyboard Maestro menu bar item and it does the rest of the work while I take a sip of my tea.
You can see the result of that automation in the video below, which will play it at full-screen and full speed, then replay it at reduced speed zoomed in to each automation step.
For the record, here’s what my Keyboard Maestro action does:
Open Audio Hijack.
Type Command-1 to bring up the Sessions window. Wait until the window appears.
Double-click on the “Podcast with Live Stream” item (matching a screen shot I took). Wait until that window opens.
Type Command-1 to bring the Sessions window back to the front. Wait until it appears.
Type Command-W to close that window, leaving just my session window visible.
Open Lingo (my IRC client, sadly discontinued). Wait until the window contains the word Freenode—in other words, until it logs in to the server.
Click 20 pixels down and 76 pixels right of the top left corner of the front window. History has shown that this will be the #relayfm channel. Wait until the title of the window changes to reflect this.
Open Nicecast. Wait half a second for it to open, and make sure the Nicecast window is frontmost.
Select the menu item Window: Show Server to open Nicecast’s Server window. Wait until the Server window opens.
Click 22 pixels to the left and 28 pixels down from the icon of a satellite dish that appears in the Nicecast interface. This clicks the “Relay FM” radio button.
Select the menu item Window: Close to close Nicecast’s Server window
Move the Nicecast window to 2039 pixels down and 1039 pixels right from the top left corner of the screen, because that’s where I like that window to be
Open a Safari window with four tabs containing the pages I need to run the show
[If you appreciate articles like this one, help us continue doing Six Colors (and get some fun benefits) by becoming a Six Colors subscriber.]