Over the last few tutorials, I’ve been covering Keyboard Maestro, the Mac automation app. With it you can string actions together to create powerful macros. They can be triggered in an almost endless number of ways, some of which I’ll show you in this tutorial.
In the first tutorial I showed you Keyboard Maestro and looked at creating a simple macro that launched the Tuts+ website. Then in the second tutorial I introduced some more features by showing you the ways to launch apps.
By now you should have a solid grasp on how to set up your own macros with Keyboard Maestro, so I’m going to begin exploring more advanced concepts in this tutorial. Not only will I look at situational triggers but I’ll also touch on some of Keyboard Maestro’s more powerful features like variables.
As always, you’ll need to have read the preceding tutorials:
You’ll also need to have a copy of Keyboard Maestro installed. You can download it from the developer’s website. There’s a 30-day free trial and after that it costs $36 for a license.
To be frank, if you’ve reached this point in the series I’d recommend just buying the app outright. You’re now at the point where you’ve invested enough time into setting it up that it’s silly to have it stop working after a month.
My Macros Don’t Have to Be Your Macros
As I dive deeper into Keyboard Maestro the macros I use in the tutorials become more and more specific. Whilst you can copy what I do exactly while you’re figuring out the app, I recommend you look critically at what I do and think how something similar could fit into your workflow.
Never be afraid to do something different to what I recommend. Keyboard Maestro is the most personal app I know of.
Opening and Closing Email Every 4 Hours
Email is the bane of my existence. If I leave my email app open I’ll get several notifications an hour all of which will distract me from real work. It’s very rare that an email is actually urgent.
Many people have written about the benefits of having a set time to check email. It’s something I’ve been trying to implement and I use Keyboard Maestro to automate it. With this pair of macros your email app of choice will open and close at specific times.
Create a new macro called Check Email. Add a Time Trigger that activates the macro At time: 12:00 on every day of the week. Add as many more triggers as times you want to check your email throughout the day. I’m fairly nocturnal, prone to working odd hours and email is a distraction so I have it trigger at 16:00, 20:00 and 00:00 every day of the week.
If you work a nine-to-five job where email is important, you might set it to trigger every work hour on week days.
For the action, have Keyboard Maestro Open your email app of choice. In my case, it’s Airmail.
Create another macro called Close Email. Add the same time triggers but offset by around twenty minutes, or however long you think you’ll need to deal with email. For me, it triggers at 12:20, 16:20, 20:20 and 00:20.
Set the action to Quit Airmail, or whatever email app you’re using.
With this set up, your email app automatically opens every four hours for twenty minutes. That’s it; no more annoying pings.
Using Wi-Fi Networks to Trigger Macros
One of the situational triggers with the most potential is the Wi-Fi trigger. It’s unlikely that any two places you visit will have the exact same wireless network name so it can be used as a pretty good proxy for location.
As a writer, it’s easy for me to stay cooped up all day. To make sure I get out and about I occasionally go work in a local coffee shop. I use the wireless network’s name to trigger a macro that sets my Mac up for working in public.
Create a new macro called Work In Coffee Shop. Give it a Wireless Network Trigger. There are a couple of coffee shops I use so I have the macro trigger if the wireless network with name containing starbucks is connected. If there’s only one place you want to trigger the macro, set it so that it exactly matches the network name.
For the actions, have the macro configure your normal working set up. I have it mute the Mac’s audio, execute the Start Work macro I created in the last tutorial, quit some distracting apps and open Spotify.
From the System Control category, use a Set System Output Volume to lower the Mac’s volume to zero. The Toggle System Sound Mute action won’t work properly: if the Mac is already muted it will un-mute it.
Next, from the Execute category have Keyboard Maestro Execute a Macro. In the previous tutorial I created the Start Work macro that sets up Byword and Google Chrome side-by-side. Repeating the same actions all over again would be pointless.
After that, use Quit a Specific Application actions to close down any distracting apps. For me they’re Tweetbot and Slack.
Finally, use an Open action to launch Spotify. It might strike you as odd to launch Spotify after muting the Mac. The reason for the mute action is so the Mac doesn’t make noise unexpectedly.
Once I’m set up, I connect headphones and turn the volume back up so I can listen to music.
Tracking Work With Screenshots
I really like tracking what I do. I already use services like RescueTime to keep track of how long I work for and how much I procrastinate. As great as it is, there’s nothing like having a time-lapse of how you use the Mac throughout the day.
With this macro, Keyboard Maestro takes a screenshot every five minutes and saves it to Dropbox. It’s then simple to create a video that shows a full eight hour work day in ten or fifteen seconds. It’s not a perfect record but it does give a good overview.
Create a new macro called Track What I Do. Assign it a While Logged In Trigger that activates every 5 Minutes Between 00:00 and 23:59 every day of the week. If you only want to track work hours, change the times and days here.
From the Image category, add a Screen Capture action and set it to Capture main screen. You need to assign a clipboard that the image is sent to. I recommend you create a new one called Track from the dropdown menu.
Next you need to use a variable—a Keyboard Maestro feature I haven’t touched on yet—to get the time and date so the file can be named properly.
From the Variables category select a Set Variable to Text action. Call the variable tracktime. You can set the variable to anything you want and, using Tokens, include dynamic information. I want to have the files named by year, month, day, hour, minute and second.
For example, a screen capture taken at this moment would be called
Track_2015_03_18_211000. You can create this same pattern using tokens or copy and paste
Track_%ICUDateTime%yy_MM_dd_HHmmss% into the to: field. Beneath the action you can see a preview of what value the variable will have.
Next, add a Write to a File action from the File category. Have it Write Named Clipboard Track as a JPEG file. For the location paste in
/Users/harryguinness/Dropbox/@Tuts/Track/%Variable%tracktime%.jpg replacing everything before
%Variable%tracktime%—the call to the variable you created a moment ago—with the path where you want the image saved. I have a Track folder in Dropbox.
With that done, Keyboard Maestro will start taking screenshots every five minutes and saving them to the Mac.
In this tutorial I’ve looked at some of the situational triggers Keyboard Maestro offers and touched on some of the app’s more advanced features. With the information I’ve covered in the last three tutorials you should really be beginning to get a feel for the app.
While I’m not going to cover every feature offered in this series, by now you should be able to puzzle out how most of them work.
If you’ve any questions or workflows you’d like me to cover in future tutorials, let me know in the comments.