Apologies also for extending this discussion, but it does seem the easily overlooked AppleScript gethotkeys command from the Keyboard Maestro Engine Suite might provide parallel access to the dynamic list of Show Active Macro Groups.
If it does what it says in its AppleScript defintion, it may provide what @dtremit is looking for:
"gethotkeys (verb): Gets an array of groups of arrays of macros that are currently available via hot keys or typed string triggers." (from Keyboard Maestro Engine Suite)
Here is a macro that uses a prompt list to display names and uids from the command's output (an in-memory plist).
Its default is to display gethotkeys groups. I hope the list is close to that of the Show Active Macro Groups in the Status Menu.
Alternatively. it can be set to display the macros in those groups instead. (Set the value of localActiveCollection to "macros")
By default, the prompt list shows macros "currently available via hot keys or typed string triggers" as described in the gethotkeys definition.
Alternatively, it can be set to use the getall parameter described in the AppleScript definition: "retrieves all active macros, not just hot key and typed string triggered ones"
(Set the value of localGetAll to "true")
Active Groups Or Macros in Prompt List.kmmacros (12.5 KB)
Here is the AppleScript
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
property scriptAuthor : "@CRLF"
--┏━━━━━━━━━━━━━━━━━━━━━┓
--┃ Purpose:
--┃ Get gethotkeys data
--┃ into a uid__name text list for display
--┃ in a prompt list
--┗━━━━━━━━━━━━━━━━━━━━━┛
if "KMINSTANCE" is in (system attribute) then
set kminstance to system attribute "KMINSTANCE"
tell application id "com.stairways.keyboardmaestro.engine"
set macrosOrGroups to getvariable "localActiveCollection" instance kminstance
set getAll to (getvariable "localGetAll" instance kminstance) is "true"
end tell
else --to run as a standalone script, set options here:
--setttings are: {"groups"|"macros", boolean}
set {macrosOrGroups, getAll} to {"groups", false}
end if
set activeCollection to GHK(macrosOrGroups, getAll)
--sort by name (sort key = name minus any leading sort specifiers, eg. 01)
set sd to current application's NSSortDescriptor's sortDescriptorWithKey:"sort" ascending:true selector:"localizedCaseInsensitiveCompare:"
set activeCollection to activeCollection's sortedArrayUsingDescriptors:{sd}
-- a dictionary with values of just the keys "sort" and "uid" set to arrays of names and uids
set activeCollection to activeCollection's dictionaryWithValuesForKeys:{"sort", "uid"}
--parallel pairs of arrays
set {names, uids} to (activeCollection's objectsForKeys:{"sort", "uid"} notFoundMarker:"not found") as list
set promptList to current application's NSMutableArray's array()
repeat with i from 1 to (count of names)
(promptList's addObject:(item i of uids & "__" & item i of names))
end repeat
if macrosOrGroups is "macros" then
--Get a unique set of uids.
--(gethotkeys has entries for each trigger, so if a macro has more than one trigger, its uid will appear more than once.)
set promptList to (current application's NSOrderedSet's orderedSetWithArray:promptList)'s array()
end if
return (promptList's componentsJoinedByString:linefeed) as text
on GHK(macrosOrGroups, getAll)
tell application id "com.stairways.keyboardmaestro.engine"
if macrosOrGroups is not in {"macros", "groups"} then error "GHK parameters are: \"groups\" or \"macros\" and true/false"
--coerce AppleScript property list data to NSData
if macrosOrGroups is "macros" and getAll is true then
set theData to (current application's NSArray's arrayWithObject:(gethotkeys with getall))'s firstObject()'s |data|()
else
set theData to (current application's NSArray's arrayWithObject:(gethotkeys))'s firstObject()'s |data|()
end if
end tell
--deserialize to plist object. The heirarchy is the same as the Keyboard Maestro Editor: groups containing macros.
set {groups, theError} to current application's NSPropertyListSerialization's propertyListWithData:theData options:0 format:(missing value) |error|:(reference)
if groups is missing value then error (theError's localizedDescription() as text) number -10000
if macrosOrGroups is "groups" then
return groups
else if macrosOrGroups is "macros" then
--unnest macros
set macros to groups's valueForKeyPath:"@unionOfArrays.macros"
return macros
end if
end GHK