Automation Documentation: Hooking Keyboard Maestro

In my post yesterday, I described how I was using Obsidian and Hook to help me support my documentation of automations. Today, I am going to share something that helps me work with documenting Keyboard Maestro macros.

Keyboard Maestro

If you have ever looked for utility and flexibility with your automations on macOS, the chances are pretty high that you will have come across Keyboard Maestro. Keyboard Maestro is a tool that allows you to build sets of macros that can be activated by a wide variety of triggers and execute a wide variety of automation steps. It is a core tool in my Mac automation tool set.

While Keyboard Maestro does provide comment blocks in macros and notes fields for action blocks, they are quite limited in terms of trying to be comprehensive with documentation. For example, you are not going to get a diagram or hyperlinks in those places. Being able to link out to Obsidian via Hook opens up a plethora of options around how I can document something in Keyboard Maestro.

The one issue that is presented is that out-of-the-box, Hook does not have support for Keyboard Maestro.

Keyboard Maestro Integration Script

Pro subscribers of Hook can create their own integration scripts that allow Hook to work with any app capable of supporting hyperlinking to a specific resource. Fortunately, I have a pro subscription, Keyboard Maestro is scriptable, and I was able to put together an AppleScript to allow an address to be generated by Hook for a macro or macro group.

The script is added via the script editor in Hook’s preferences. It should be added in the Get Address section as the script returns a Markdown link.

tell application "Keyboard Maestro"
    try
        set selKMMacros to selectedMacros
        if ((count of selKMMacros) = 1) then
            set chosenMacro to first item of (get selection)
            set chosenMacroID to id of chosenMacro
            set theURL to "keyboardmaestro://m=" & chosenMacroID
            set theName to name of chosenMacro
            return "[" & theName & "](" & theURL & ")"
        end if
    end try
end tell

Once in place, this will allow you to generate an edit macro/group link when you select a single macro or macro group in Keyboard Maestro.

Summary

Being able to bidirectionally link to a note in Obsidian to create documentation for my Keyboard Maestro macros has been great. Not only does it allow me to seamlessly jump to documentation on my macros, but since the introduction of subroutines in Keyboard Maestro, Hook and Obsidian also make it really easy for me to link up to the documentation of those subroutines, and to find out which macros will be affected by any changes to that subroutine.

Author: Stephen Millard
Tags: | keyboard maestro | hook | hookmark | applescript |

Buy me a coffeeBuy me a coffee



Related posts that you may also like to read