The following AppleScript creates a list of all macros in a group (“local__groupName”), which is determined by the calling macro trigger. How can I modify it to create a list of only the enabled macros in that group?
set inst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
set targetGroup to getvariable "Local__GroupName" instance inst
end tell
tell application "Keyboard Maestro"
set outputList to ""
set macroList to every macro of macro group targetGroup
repeat with curMacro in macroList
set macroUUID to id of curMacro
set macroName to name of curMacro
set outputList to outputList & macroUUID & "__" & macroName & "
"
end repeat
return outputList
end tell
That is, how can I modify:
set macroList to every macro of macro group targetGroup
tell application id "com.stairways.keyboardmaestro.editor"
set enabledMacros to macros of macro group targetGroup whose enabled is true
end tell
Or combine it with a properties batch query to get lists of id and name in one go.
tell application id "com.stairways.keyboardmaestro.editor"
set {macroUUIDs, macroNames} to {id, name} of (macros of macro group targetGroup whose enabled is true)
end tell
set outputList to ""
set i to 1
repeat with macroUUID in macroUUIDs
set macroName to item i of macroNames
set outputList to outputList & macroUUID & "__" & macroName & "
"
set i to i + 1
end repeat
return outputList
Instead of iterating through macro objects and making an AppleScript call per property, it gets the properties in one AppleScript query.
You can then iterate through regular AppleScript paired lists to format your string.
You probably won't notice a speed difference until your macro group contains a large number of macros.