Great!
I'm on Mojave, so I am always concerned about how uploads run/perform (or don't
) on other setups.
FWIW, KM Engine's gethotkeys command also provides an in-memory plist that is almost as fast as KM Editor's AppleScript. Its plist (without the with getall option) is instead a dynamic subset of macro groups of currently active macros that are available thru hotkey or typed string trigger.
gethotkeys scripting definition

In the uploaded script, swap out "getmacros" with gethotkeys. Run the subroutine when different apps are frontmost and you'll see how it works.
tell application id "com.stairways.keyboardmaestro.engine" to set groups to current application's NSPropertyListSerialization's propertyListWithData:((current application's NSData's dataWithData:(gethotkeys))'s |data|()) options:2 format:(missing value) |error|:(missing value)
To see the full set of ALL active macros in the group use:
gethotkeys with getall
It pretty closely, if I remember, follows what the "Active Macro Groups Palette" displays, which is also dynamic.
Show Active Macro Groups Menu
