Suggested Wiki Content: Plug-In or Macro Subroutine?

@JMichaelTX suggested that the wiki entry on plug-ins might need some clean up or additional information. I'll probably make suggestions for some clean up as I get time but I lost track of time and wrote this whole thing below up before considering if it would be useful. Feel free to add to the wiki if it's appropriate.

Plug-In vs. Macro Subroutine

Keyboard Maestro’s Execute a Macro action can act as a subroutine: A sequence of actions that you’ll use frequently in different macros can be consolidated into a single standalone macro and called via Execute a Macro when needed.

Plug-Ins offer a similar functionality, so when should each be used? In Keyboard Maestro plug-ins have a unique capability not available with Execute a Macro. Keyboard Maestro Plug-Ins have defined fields that are used to pass data to the Plug-In for it to act on.

To accomplish this with Execute a Macro, Global or Instance variables are setup which the excuted macro can use (Local variables can not be shared between macros.) Each time you use the macro you’ll need to remember which variables to setup. A plug-in’s form details all this for you.

There are 2 main advantages Execute a Macro action has over Plug-Ins:

  1. They can use Keyboard Maestro Actions
    • Plug-Ins can only run Applescript or shell scripts
  2. They can access all Global and Instance variables
    • Plug-Ins can only use the Keyboard Maestro variables explicitly passed to it via its form.

Generally you’ll typically want to use a subroutine macro, but you might consider a plug-in if your action needs more than a few variables passed to it and if it’s actions can be contained in a shell or Applescript.


Need: Move the mouse to a set destination, click a button, move the mouse back to it’s original position.

Plug-in or Macro subroutine? You only need to send two variables: the mouse destination coordinates and which button to click. The mouse movement actions are built-into Keyboard Maestro and are difficult to do via Applescript or shell script. This example will probably work best as a subroutine macro.

Need: Send an email without using Apple Mail

Plug-in or Macro subroutine? Keyboard Maestro has a Send Mail Message action but it only works with Apple’s mail, if you’re a webmail user Apple mail probably isn’t setup for you. Looking at the Send Mail Message action it’s clear sending a mail message needs a lot of parameters: To, CC, Bcc, Subject, From, Body, Attachment.

Sending mail messages via shell scripts is a solved problem. It may take a bit to puzzle through some arcane command-line syntax but there should be plenty of examples to work from. This would probably be a good solution for a Plug-In.