Show Macro Group %variable% for One Action?

Needed for a long time but too timid to ask: new year, new audacity :wink:

In this action:


how to manage to parameter the Macro Group name (or Macro UUID) programmatically?

Any ideas?

Thanks,
-- Alain

You can’t do it, so as usual there are two ways to accomplish it.

If there is a finite number of possible groups, then simply use a Switch statement:

  • Switch on variable MyGroup
    • is “Group A”
      • Show palette for one action Macro Group “Group A”
    • is “Group B”
      • Show palette for one action Macro Group “Group B”
    • is “Group C”
      • Show palette for one action Macro Group “Group C”

Alternatively, you can use the XML for the action, insert the group name into the XML template, and then use do script to execute it. This is tricky, but not that hard. See Controlling Keyboard Maestro via Scripting.

1 Like

Is there any hope for a future third way: incrementing the KM ToDo list of more a thousand items?

A lot of power: thanks Peter to recall to me...
-- Alain

I know about tokens %ExecutingMacroGroup%,
%MacroNameForUUID%UUID%.

But to use the XML for the action, I need a way to convert a string “name of a given group/macro” in string “group/macro UUID” so something like %MacroUUIDForName%Name% I don’t find…

How I can do it?

– Alain

Its possible, but its not really something that has come up, so its hard to imagine it would be high enough priority to allow for the fact that it would require a whole new UI to do it.

You can use the process tokens AppleScript command on the Keyboard Maestro Engine to process a token to return the UUID.

I can't figure out to find UUID of a named group with the "Keyboard Maestro Engine" dictionary:

Where to find some lightning example?

-- Alain

Hey Alain,

I believe there is no method of going from macro NAME to macro UUID.

The only token I’m aware of is MacroNameForUUID, so you can go the other direction.

I believe your primary need is the UUID of macro and group, but I have only run a very few tests using macro plists.

Perhaps you should post some pseudocode to show what you’re trying to do.

Oh, you can parse the whole Keyboard Maestro macro list by getting it with AppleScript and then using KM’s regular expressions to search. (I would just stay in AppleScript and use the Satimage.osax myself.)

tell application "Keyboard Maestro Engine"
  set kmPlist to getmacros with asstring
end tell

-Chris

1 Like

@ccstone is (unsurprisingly) correct, there is no UUIDForMacroName token since there might be multiple UUIDs for a given name, there would be no way to know which one.

Parsing the list of all macros would currently be the only way to find it.

@ccstone Here is my pseudo code I want to use at run time:

Set Variable ‘tmp’ to Text "a_given_palette_name"
Show Macro Group ‘%tmp%’ for One Action

Thanks for the track, but I have already tested and rejected: to long processing duration for real time use, need of caching mechanic, etc.

Peter I agree (of course) with you when you are pointing the non necessary uniqueness of a given macro or a group in KM.

But in such rare and perhaps pathological situations (in this context a such use of naming) an hypothetical token %MacroUUIDForName%Name% can just take the UUID of the first object it founds... In the same way, if a name don't exist it will return ""... and the KM user using this token will take the appropriate behavior as usual.

If I even more advocate for such a token, please consider how an already existing similar feature (action about a named KM object) is working nicely through KM AppleScript here.

Every thing is OK (works) apart the mapping KM group name => UID
Show Macro Group group_name for One Action (emulation).applescript.zip (440 Bytes)