Keyboard Maestro: Mac Restriction29 Jul 2022
I am fortunate enough to have a couple of Mac computers. An old Mac mini functions as an always on Mac carrying out tasks on demand and on a schedule, whereas my slightly newer Macbook Pro is the machine I use directly. But, I have Keyboard Maestro installed on both machines, and I needed to be able to determine which machine a macro was running on in some cases, as in some cases it should not run at all. This was particularly the case with scheduled macros. In this post I am going to share a couple of macros I am using for this.
There really is not much to these macros, the magic lying in what Keyboard Maestro does. But, I figured it would be worth sharing in case anyone is looking for a simple, efficient, and reusable option.
Previously I had coded soemthing similar to the below macros into each macro that required it, but with the release of Keyboard Maestro 10 last year I was able to simplify this by creating two subroutine macros. One subroutine macro that will halt macro excution if a provided name does not match the Mac’s name, and one that will halt macro exeution if it does match the provided name.
Here are those macros.
Each of the macros takes the computer’s name via a parameter
instanceCheckMacName, so you can use them flexibly across many macros.
Here is an example where I only want to run a temporary TextExpander snippets clean up on a Mac called “Polymath”. I include a call to the “Continue If Machine Name Is” subroutine macro passing in the Mac name. The subsequent AppleScript will execute only if the macro is running on “Polymath”.
Often, the most useful automations are some of the simplest and I think these macros are a good example of that.