Template Macros

Maybe this exists but I couldn’t find this so point me in the right direction if it does.

I would love to have been able to create template macros and reuse them with different parameters.

For example, I have several macros that activate an app only if it is already running, otherwise they activate another app (Safari if it is running, otherwise Chrome, Sublime if it is running, otherwise intellij, etc…)

I would like to create a template that I can reuse. This could be really cool:

  • SwitchIfRunning(Safari, Chrome)
  • SwitchIfRunning(Sublime, Intellij, QuickText)

I come from Windows where I could do stuff like this with Autohotkey.

Is there a way to achieve this? If not, I’m suggesting a feature :smile:

Thanks. Love the app!

1 Like

You can make a macro that uses variables, and call it from other macros that set these variables.

There is no way to create a template macro that asks for settings and then creates a customised macro.

As @philippe says, you can create a macro that uses variables, and then create other macros that set the variables and then execute that subroutine (although that does not work well in this case as you generally cannot use variables in places in Keyboard Maestro where it wants an application).

You can create a macro and then save it to your Macro Library. You can then add it each time and then adjust the parameters as necessary. This is pretty much functionally equivalent to just selecting an existing macro and duplicating it and then adjusting the parameters which is probably easier.

Currently I am using the same method as you described. The problem with that is, if we make modifications in the template macro, I need to visit each macro manually to replicate the modifications.

As we are talking about a concept of 'templates', these are used at multiple places (multiple macros). Hence when we make templates more efficient, it improves our productivity multifold. So we are naturally inclined to make them better as our knowledge grows. Also, it is possible that the use case differs slightly so we just need to make a few changes in the templates.

In short, templates are subject to constant modifications. So I'd be very advantageous to have a feature or at least a workaround to be able to reflect the template modification all at once in all macros.

If you want the macros all to use the same actions, then you probably want a Subroutine or Sub-Macro executed with Execute a Subroutine or Execute a Macro actions.