Alfred Workflow - Keyboard Maestro

If you speak to anyone who more than dabbles in automation on macOS, Keyboard Maestro is almost certainly going to be a utility that gets mentioned. I’m certainly no stranger to the application and have been using it for over a decade to manage a large proportion of my Mac automations. But when you invest like that, you do tend to build up a large set of macros and having memorable ways to access them with short codes, hot keys, gestures, palettes, etc. can become a little overwhelming. I’m personally much better at remembering parts of the names and so searching an index of the available macros helps me with the ones I don’t have in regular circulation, and that’s what today’s Alfred workflow enables.

Workflow: Conductor

I’ve named the workflow for working with Keyboard Maestro “Conductor”, as it is directing the maestro. At it’s core it is simply a way to list and execute a particular macro, but I may just have added a few more bells and whistles along the way as you can see from the workflow layout.

Download Conductor

Prerequisite: Python 3 (Easy step-by-step install for Python 3).

For more Alfred workflows, take a look at the downloadable workflow list on the Alfred project page.

About Conductor

The following description is included in the Workflow.

Keyboard Maestro is a third party utility that allows you to build and run macro-based automations to interact with other applications and the operating system. It provides an Automator-like user interface with a large array of triggers and actions, and with support for triggering scripts and targeting actions on user interface elements (e.g. buttons and menus).

Conductor is a workflow for interacting with Keyboard Maestro and specifically for working with macros. It utilises seven different trigger keywords that allow you to carry out various actions.

km {macro name}
A script filter to execute a macro by name. Type in “km” and a list of active macros will be displayed in alphabetical order. Beneath each macro name listed, you can also see what macro group it belongs to and it’s unique ID. Continue typing to filter the list and use the usual Alfred navigation options to select the macro you wish to trigger.

As well as executing a macro, you can instead opt to edit a macro by holding down the “alt/option” key when selecting, to copy the macro’s name to the clipboard by holding down the “cmd” key when selecting, or to copy the macro trigger URL to the clipboard by holding down the “ctrl” key when selecting.

;km {delay in seconds}
When the workflow is installed, you can set a variable called “delay”. This variable is used by the “#km “ keyword call to trigger a macro after a specified number of seconds delay. Using “;km” you can specify a positive integer value for the number of seconds delay without having to open and modify the variable inside the Alfred workflow. Effectively it is a quick access approach.

Note that the current value of the delay is shown in the subtext for the action when you enter the keyword.

.kmge {macro group name}
Enable a disabled macro group by name.

.kmgd {macro group name}
Disable an enabled macro group by name.

.kmme {macro name}
Enable a disabled macro by name.

.kmmd {macro name}
Disable an enabled macro by name.

Creating Conductor

For several years, I had been using Alfred Maestro, but it utilises a compiled set of code (written in Go). Over time I came to realise that I wanted some additional features and I also wanted something that I could tailor and debug more easily without a whole compilation routine for something so small and seemingly straightforward. The result was Conductor.

I only dabble in Python occasionally, but at the core of the Conductor workflow are some Python scripts that I created to query the Keyboard Maestro master macros plist file to get and process the required information about the macro groups and macros. Beyond that, it is just utilising core functions of Alfred’s workflow functionality and bits of AppleScript to control Keyboard Maestro.


Being able to access Keyboard Maestro macros quickly and easily by name is something that I’ve come to rely on. The main driver for me at the beginning was the sorting of the macro names alphabetically. There’s simply something about the alphabetical ordering that makes it easier for me to review and narrow my searching versus the recency that Alfred Maestro uses. I think for many people that recency is useful, but for me, my use is less about frequency and more about narrowing the field from everything each time, and so that broader ordered scope is simply what works best for me, and I expect that there are others out there that this is true for too.

With any luck you will find my approach, and the features I’ve included in this workflow, a good match for how you would like to work with Keyboard Maestro. I hope that you get as much benefit from it as I do.

Author: Stephen Millard
Tags: | alfred | keyboard maestro |

Buy me a coffeeBuy me a coffee

Related posts that you may also like to read