[Feature Request] To include the Macro Group of the target macro besides its name, in the "Execute Macro" macro

Nested actions can be also be searched from a macro's xml with xpath.

However, directly getting/setting the properties of the found actions still requires interacting with the nested actions either thru UI selections or as script objects. Either approach can work by using the Editor's "selectAction" and the actions ids from the xpath query to select each found action.

At the bottom of the post is a macro that scripts nested actions.

Rather than rely on the selection object to get action objects, I've tried to implement a novel, I think, approach: getting a "runtime" AppleScript object from xpath results that can be used as an ordinary action by Editor AppleScript.

Not even in the proof-of-concept phase, this is more experimental ... or just plain ill-advised.

This demo just searches for user-specified types of actions at any nest levels and displays the names of found "runtime actions".

If, by chance, it does not fail utterly, its "runtime" list of actions could be fed into @Nige_S's script to color code nested inside/outside-current-group subroutine actions. All color changes could be made in one pass, requiring only that the macro be selected.

(It may be useful to know that when setting properties, such as color, xml or name of an action with AppleScript, pressing the ⌘+z keys will restore the old values.)

PURPOSE:

Demo how to query nested actions in a macro with xpath and use results as "runtime actions" .

ACTION:

Displays the names of types (specified by the user) of actions at all levels as "runtime actions" in the currently selected macro.

USAGE:

  1. Enter the type of actions to display in the value field of the "localMacroActionTypes" variable.

  2.    Each action type must be on a separate line.
    
  3.    Select a macro that contains the specified types in the Editor. Run the macro by the trigger of your choice.
    
Configuration Screenshot

Select any action in the Editor, click the gear icon :gear:, select Copy As XML, copy the value of the "MacroActionType" key and paste it into the value field of the "localMacroActionTypes" variable. Each type must be on a separate line. The default type is "SetVariableToText". The macro will do nothing if the specified MacroActionType is invalid.

Tested on Mojave running KM Version 11.0.3

Implementation Overview
  1. Calculate a list of AppleScript action paths from the ancestors of an xpath found "action nodes" (NSXMLNode).
  2. Convert the list of paths to a list of references with "run script()" and dereference the list of references by rapping and unwrapping each reference "as list" to get a list of AppleScript action objects.

Editor AppleScript can then use the "runtime actions" as ordinary actions to get/set action property values:

tell application id "com.stairways.keyboardmaestro.editor"
set anActionName to name of action id "16957523" of macro id "3E27DB15-15B0-4E8E-BE6B-FA1460FB884D"
set name of action id "16957523" of macro id "3E27DB15-15B0-4E8E-BE6B-FA1460FB884D" to "01)" & anActionName
end tell

Thanks and apologies in advance to those patient enough to read this far much less try the macro.

Test Runtime Actions Macros.kmmacros (23.8 KB)