Keyboard Maestro IconKeyboard Maestro

Conduct your Mac Like a Pro!


The primary scripting interface to Keyboard Maestro is the Keyboard Maestro Engine’s do script support. You can ask Keyboard Maestro to:

Note in all cases you must ask "Keyboard Maestro Engine", not "Keyboard Maestro".

The easiest way is to use the name, for example:

tell application "Keyboard Maestro Engine"
  do script "Switch to Last Application"
end tell

The macro must be defined and currently active.

If there is more than one macro with the same name, they will all be executed, so by preference you can use a UID instead of a name.

tell application "Keyboard Maestro Engine"
  do script "D0C150C7-8A0C-4837-918A-427E2BCFB6B9"
end tell

The easiest way to determine a macro’s UID is to export it and then open the exported file and find the UID field.

An even more powerful way to script Keyboard Maestro is to execute specific actions based on their XML code. This allows you to construct any action, including changing the action on the fly, without having to create a macro first. A simple example would be:

tell application "Keyboard Maestro Engine"
  do script "<dict><key>MacroActionType</key><string>SwitchToLastApplication</string></dict>"
end tell

Again, the easiest way to determine the appropriate XML is to create an example action in an example macro and then export the macro.

Continue on to Windows


Feedback Form

Please provide any feedback you may have

Email Address:

Your email address is appreciated but is not required and will not be saved.
It will be used only for responding to or clarifying this feedback.


Keyboard Maestro

Old Documentation