Run KM script via Python

Is there any way I can run KM script via python?

You can run applescript from Python.

This applescript :

  osascript -e '
    tell application "Keyboard Maestro Engine"
    do script "my macro"
   end tell

Will run your macro. Change my macro to your macro’s name of course. :slightly_smiling_face:

1 Like

In the Trigger section of any of your KM macros open the "Or by script" menu

and select "by Python script":

Then you get a pre-made Python snippet to run your macro:

Copy-paste that into your script.


Thank you Tom and nikivi.