The first Mac program I ever bought was CE Software’s QuicKeys, back in 1989. Although I’ve used different macro utilities over the past 22 years — KeyQuencer, OneClick, iKey — there has always been one on every Mac I’ve owned, and my current favorite is Keyboard Maestro, from Peter Lewis of Stairways Software. For those things I absolutely need, such as switching applications by pressing F-keys, entering a few text strings I use constantly, remapping or creating keyboard shortcuts in various applications, automating moving data from one application to another, applying BBEdit text factories to clipboards, performing actions at particular times, and more, Keyboard Maestro has long done what I want. It also provides me with the capability to access previous and stored clipboards, something that enables me to avoid using a separate clipboard utility.
But every now and then, I’ll admit, Keyboard Maestro hasn’t had the power I needed. Keep in mind, I’m no programmer — I stumble along in a variety of languages thanks largely to the power of copy-and-paste. But I do understand control flow when programming, and I can use it effectively when I’m freed from the gotchas of syntax and punctuation that bedevil me every time I try to tweak some PHP or ExpressionEngine code. And that’s where Peter has taken Keyboard Maestro 5, a major update that also includes numerous other welcome additions.
Control flow basically enables Keyboard Maestro to make decisions about what to do at a given point, rather than simply running through a series of steps sequentially. Previously, Keyboard Maestro could only pause for a user-specified amount of time, but now it can pause until a particular time, use if/then/else constructions, and repeat actions while some condition is true or until some condition is met. Of course, the power here relies on the conditions against which the environment can be checked, and Keyboard Maestro offers oodles of them, including:
- Application Conditions (running, front, and the opposites)
- Front Window Conditions (exists, various title matches)
- Button Conditions (name matches, whether or not it’s enabled)
- Menu Conditions (name matches, whether or not it’s enabled)
- Modifier Conditions (whether or not they’re pressed)
- Key Conditions (whether a particular key is up or down)
- Typed String Conditions (uppercase, lowercase, or title case)
- Disk Conditions (name matches, whether or not it’s mounted)
- Path Conditions (whether or not a file or folder exists)
- Clipboard Conditions (does it contain certain content)
- Variable Conditions (does it contain certain content)
- Calculation Conditions (is the calculation true)
- Environment Variable Conditions (does it contain certain content)
- Pixel Conditions (compares the color of a particular pixel)
- Location Conditions (checks the name of the network location)
- Script Conditions (what does a script return)
As you’ll notice in that list, Keyboard Maestro supplements its control flow and condition-checking capabilities with variables and calculations, which are key for performing actions that go beyond what a smart monkey could do with the mouse and keyboard. It can also prompt for user input with text, passwords, pop-up menus, and checkboxes. Variables are stored permanently, and can contain text or arrays of numbers. You can use variables to adjust the pointer location, window size and position, and much more, and variables can be accessed from and written to by shell scripts and AppleScripts. And for some serious fun, you can even run a grep-based search-and-replace on the contents of a variable.
I’ll admit, the hard part is going to be changing my mindset surrounding Keyboard Maestro. For the most part, I only think about automating sequential tasks that are easily translated into step-by-step macros. At various times in the past when other utilities have provided similar capabilities, I have been unable to figure out just how to translate the real world environment of my Mac into a macro that could make decisions.
For instance, here’s a task I’ve never been able to automate before. For tracking which TidBITS issue number will appear on which date, I make calendar events on every Monday in BusyCal, incrementing the issue number for each one. But since we take a few issues off each year and sometimes have special issues, it’s not entirely regular. Complicating the issue is that making these events can’t be done entirely from the keyboard, and my experience is that bringing mouse clicks into any macro makes it prone to breaking as soon as the window moves. And of course, there is the simple fact that not every calendar month looks the same — some months have four Mondays, some have five, and sometimes there are Mondays from the previous or subsequent months that appear in the first or last slot in BusyCal’s month view. I haven’t had sufficient time to work through all the complexities of this macro, but with Keyboard Maestro 5.0, I’ve already come closer than ever before — the next step is either to use incremented variables to simulate clicking on each successive Monday in a month, or to copy the date from BusyCal’s Info panel and use variables to increment the day appropriately.
Keyboard Maestro 5 goes beyond just adding programming capabilities. It also features significantly enhanced clipboards, so you can now use Quick Look to show entries in the clipboard history and named clipboard switchers, send clipboards to other Macs running Keyboard Maestro (with its Web server option enabled), and perform grep-based search-and-replace actions on the contents of a clipboard. I’ve become utterly addicted to Keyboard Maestro’s clipboard history, and I even have a macro that pastes the second-to-last item copied — I find that I need to access it frequently.
New actions enable Keyboard Maestro to speak text, play sounds, display text via Growl or in a custom window, and search the Web. Plus, existing actions have been enhanced, so Keyboard Maestro’s Quit action now has options to relaunch and force quit, and lets you operate on the current application, whatever it may be. The Open File, Open Folder, and Open URL actions now let you specify particular applications to use, rather than relying on the Finder’s defaults, and Growl actions work even if Growl isn’t installed. I often have to open PDFs in Acrobat Pro 9 (my default is Preview) so I plan to create a macro to do that with a simple keystroke rather than using Open With (slow), dragging to the Acrobat Pro icon in the Dock (a long drag), or using LaunchBar (a fussy approach I can never remember).
Keyboard Maestro 5 also features many more tokens, which are bits of text picked up from the environment, like date and time. New tokens include the contents of variables, named clipboards, current track info from iTunes (name, album, artist, and rating), current application name, current mouse location, front window details (name, size, position, and frame), screen size, system volume level, address book details (name, first name, last name, nickname, and organization), and the names of the executing macro and its macro group.
As I write that, I feel a little badly about simply listing so many enhancements to Keyboard Maestro, and I do it not because I think everyone cares about each particular item, but to jog the imagination of those people who have previously been stymied in their attempts to automate some task. To give you a sense of just how massive this upgrade is, I still haven’t listed all of Keyboard Maestro 5’s new features.
But in the end, just as I considered Keyboard Maestro 4 essential for my everyday Mac usage, I think Keyboard Maestro 5’s new features will merely make the application all the more essential. You may not be as addicted to automation as I am, but I’m confident in saying that without macro-based automation, I’d be a far less productive Mac user.
If you’re using Keyboard Maestro 4, version 5 provides a ton of new capabilities for you to take advantage of for an $18 upgrade price, through 31 August 2011. After that date, and for owners of pre-4.0 versions, the upgrade costs $25, and new copies cost $36 (for an individual to use on up to 5 Macs). Keyboard Maestro 5.0 requires Mac OS X 10.6 Snow Leopard, and is 64-bit native. Although Keyboard Maestro 4.4 is available from the Mac App Store, Apple hasn’t approved version 5.0, and unfortunately, there’s no way to transfer licenses to or from the Mac App Store, though those who purchased 4.4 on the Mac App Store will receive a free upgrade to 5.0 when (and if) Apple approves it. A free trial version is available as a 12.7 MB download.