I'm afraid that I'm missing something that has already been solved here: I want to add a menu item to edit a specific macro. I came up with this:
But it handles only an active action in the specific macro.
The menu item:
I'm afraid that I'm missing something that has already been solved here: I want to add a menu item to edit a specific macro. I came up with this:
The menu item:
Add the macro to the KM Status menu, as you've done. Option-select the menu item when you want to open the macro in the Editor.
Or have I misunderstood?
Thank you Nige. I wasn’t aware of that. While it certainly is a good option, I was wondering whether it’s possible via AppleScript. This would have the advantage that I could use a keyboard shortcut to edit the macro. To be precise: to enable or disable the actions in that macro.
Sure. You could also use the keyboardmaestro://m=macro-UUID
method that's documented here.
In your OP you wanted to add a menu item. If you want to have the edit option from both the name and keystroke you could either
To include the option to "edit this macro", just add
...to an "If" with the appropriate Conditions.
Do you always want to enable/disable the same actions? You're generally better off simply putting them in a conditional block so they are or aren't executed -- which also means you don't need to have the KM Editor open.
But if you do want to do it with AS you'll need to know the macro and action(s) IDs. At which point (use your own IDs):
tell application "Keyboard Maestro"
tell macro id "F9A89CF4-D9C2-4DCD-9F48-B81D6BE5FB78"
set enabled of action id "16583730" to true -- or false to disable
set enabled of action id "16583737" to true -- or false to disable
end tell
end tell
This is very nice. Also the AS to toggle actions directly.
Where do I get the action ID? I took it from the XML copy:
And inserted 16529172 in an AS action. But that gave an error ... I guess that this is the case because the action is embedded in a group? How should I address it then?
Thank you for all great help this year. Have a wonderful Christmas!
Easiest way is to get the reference is to select the action in the Editor then run the following (which can, of course, be put into a macro):
tell application "Keyboard Maestro" to return item 1 of (get the selection)
And yes, an action can be "inside" an action and so on:
action id "16583730" of thenactions of action id "16583742" of action id "16583735" of macro id "F9A89CF4-D9C2-4DCD-9F48-B81D6BE5FB78" of macro group id "60FE925B-A085-41DC-B552-3299C9508222" of application "Keyboard Maestro"
...then use everything up to and including the macro id
:
tell application "Keyboard Maestro"
set enabled of action id "16583730" of thenactions of action id "16583742" of action id "16583735" of macro id "F9A89CF4-D9C2-4DCD-9F48-B81D6BE5FB78" to true -- or false to disable
end tell