How to open a macro to edit by name (using some script)

I use this workflow GitHub - iansinnott/alfred-maestro: An Alfred workflow to execute Keyboard Maestro macros.

that looks like this:

On return it executes the macro.

I want to edit it so on cmd+return it will open the macro to edit in KM itself.

But how do I open the macro to edit by name? Is there AppleScript/JXA to do it?

Doesn't CTRL-CMD-M do what you want? Maybe you already know that, and you simply want a single interface for both ideas.

yea want this

I see. I didn't realize you knew about the second feature (CTRL-CMD-M) and wanted both features "merged." Not a bad idea. I guess you could ask @peternlewis. I don't see any downside to your idea.

In Keyboard Maestro, “option” means edit.

So option-return will edit the macro.

If you want to make command-return edit the macro, you are out of luck I'm afraid, as command-return does not execute the macro or do anything else. If it executed the macro, then the macro itself could detect the command modifier and edit itself, but it doesn't.

You misunderstand, this is list from

When I press some command here, I will get the name of the macro or its macro UUID. I want to then open this macro to edit from KM pragmatically (from code).

In that case you'll need to modify the Alfred workflow.

In KM you can use the Trigger Macro by Name action to show a similar list and then follow the advice given by @peternlewis without ever going near Alfred.

1 Like

Yes, but part I don't get is how can I from terminal, open a macro in KM app. Or can I?

You've lost me now: I thought you were using Alfred not term.

Way Alfred works, it executes a CLI in terminal, that CLI returns a JSON with data + commands you can run on each of the data items.

So when I press on one of the items, I then need to run some CLI command or applescript or something that will open this macro in Keyboard Maestro.

You can do this using AppleScript as follows:

tell application "Keyboard Maestro"
	editMacro "2E732D2B-060E-4ACE-BB10-2F008A7854A3"
	---	editMacro "__Test Template"
end tell

You can specify the macro's UUID or its name.

Unless I am misunderstanding, this workflow already does that:


Type km followed by the name of any of your defined macros. Use modifier to reveal the macro in Keyboard Maestro.


OMG that's true, never noticed.

Thank you @tiffle for applescript :heart_eyes_cat:

1 Like

You can use AppleScript (as shown above), or you can use the keyboardmaestro CLI tool.

1 Like

You can even combine the two, and use AppleScript from the OSX command line, as explained here:

I didn't see this mentioned in the thread above, so I've decided to add this here.

1 Like