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?
Airy
May 9, 2024, 9:06pm
2
Doesn't CTRL-CMD-M do what you want? Maybe you already know that, and you simply want a single interface for both ideas.
Airy
May 9, 2024, 9:40pm
4
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 https://www.alfredapp.com
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).
tiffle
May 10, 2024, 10:06am
7
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?
Nikita:
from terminal
You've lost me now: I thought you were using Alfred not term.
nikivi
May 11, 2024, 10:01am
10
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.
tiffle
May 11, 2024, 10:49am
11
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:
Usage
Type km
followed by the name of any of your defined macros. Use ⌘ modifier to reveal the macro in Keyboard Maestro.
4 Likes
nikivi
May 11, 2024, 2:12pm
13
OMG that's true, never noticed.
Thank you @tiffle for applescript
1 Like
You can use AppleScript (as shown above), or you can use the keyboardmaestro CLI tool.
1 Like
Airy
May 12, 2024, 8:00am
15
You can even combine the two, and use AppleScript from the OSX command line, as explained here:
Hey @gmark ,
I expect the easiest way is to use the Keyboard Maestro URL-scheme.
#!/usr/bin/env bash
open kmtrigger://macro=AFB1EE80-3A76-4E58-A0E8-4C742CBC5C5F
The last parameter is the UUID of the macro.
If/when you run AppleScript from Bash I recommend making it readable. One-liners may seem streamlined, but when you have to maintain them they can be very hard to read.
#!/usr/bin/env bash
read -r -d '' asCmdStr <<'EOF'
tell application "Keyboard Maestro Engine"
do script "AFB…
I didn't see this mentioned in the thread above, so I've decided to add this here.
1 Like