Execute a macro, using macro name, via terminal


I’m reading this page:

and from my understanding it isn’t possible to execute a macro via terminal. Just to confirm if this is the case.

I’d like to execute a macro with a 1-line terminal command “execute macro ‘dostuff’”.

Thank you.

on run argv
	set theMacro to (item 1 of argv)
	-- your script using the parameters follows
	tell application "Keyboard Maestro Engine"
		do script theMacro
	end tell
end run

then call the macro as

osascript /Users/xxxxx/Dropbox/applescripts/km_macro_as_param.scpt “macroname”

1 Like

Just in case anyone needs this :slight_smile:

In the trigger section of every macro, Keyboard Maestro shows you how to execute the macro via various scripts. From the Terminal, a shell script like this would be the easiest one:

osascript -e ‘tell application “Keyboard Maestro Engine” to do script “MACRONAME”’

Your solution is functionally equivalent though, and probably just as easy given the quoting.

1 Like