The menu action extractor would start by asking the user for the name of an app , then create an app specific group (or the user van create one) and finally generate a series of macros with all possible ‘select or show menu’ actions for that app (one per macro).
The user could then simply scroll down the list of macros in that group and select the menu actions of interest to him.
Presumably you could do it. Keyboard Maestro processes the menus and creates the popup menu in the Select or Show Menu action, but that data is not available externally, but presumably you could use JXA or ASObjC and talk to the accessibility API and get the same information and build the macros.
Perhaps, but a lot of accessibility is unavailable to JXA or to AppleScript (which now includes AppleScriptObjC of course). I’m not familiar enough with the vagaries to say in this case.
In any case it’s possible to do this now in a rather ugly way with System Events.
Run this script from the Script Editor, and you’ll get a bunch of nasty text displayed in TextEdit.
------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2017/11/21 21:33
# dMod: 2017/11/21 21:33
# Appl: Keyboard Maestro, System Events
# Task: Read Entire Contents of Menu Bar 1 of a Named Application
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @ccstone, @Keyboard_Maestro, @System_Events, @Read, @Entire, @Contents, @Menu, @Bar, @Named, @Application
------------------------------------------------------------------------------
--» Using the Keyboard Maestro editor as the test app - make sure it's running.
tell application "Keyboard Maestro"
if not running then
run
delay 0.1
end if
end tell
--» Compile all menu items of the given app.
tell application "System Events"
tell application process "Keyboard Maestro"
tell menu bar 1
set menuBarEntireContents to entire contents
try
menuBarEntireContents / 0
on error eMsg
end try
end tell
end tell
end tell
--» Write the text to a file on the Desktop.
writeUTF8(eMsg, "~/Desktop/ContentsOfMenuBar1.txt")
--» Display the file in TextEdit.
do shell script "open -a TextEdit ~/Desktop/ContentsOfMenuBar1.txt"
-------------------------------------------------------------------------------------------
--» HANDLERS
-------------------------------------------------------------------------------------------
on writeUTF8(_text, targetFilePath)
try
if targetFilePath starts with "~/" then
set targetFilePath to POSIX path of (path to home folder as text) & text 3 thru -1 of targetFilePath
end if
set fRef to open for access targetFilePath with write permission
set eof of fRef to 0
write _text to fRef as «class utf8»
close access fRef
on error e number n
try
close access fRef
on error e number n
error "Error in writeUTF8() handler of library: gen.lib" & return & return & e
end try
end try
end writeUTF8
-------------------------------------------------------------------------------------------
Once you have that text you can clean it up and have all the available menu items.
(That’s a bit of a task though.)
Once you’ve built a parser, you can change the script to work with any app.