Hey Brian,
I know what a programmatic reference is; I've been in the game for about 40 years.
What I didn't know is what you meant.
- You didn't say you wanted an AppleScript reference (vanilla or UI).
- You didn't say what your ultimate objective was.
- Now you're telling @Sleepy you want a string, but you previously said you want a reference to the selection object...
So. You weren't very clear about what you wanted or why. Hence the query.
Glad to hear it. Most people are.
Not for most people. They take one look, and their eyes roll back in their head...
I've been using and evangelizing UIB since 2005.
Script Debugger is also an anodyne for UI-Scripting if one knows how to use it.
You can definitely get down into the open menu object if you know what action you're working with:
tell application "System Events"
tell application "System Events"
tell application process "Keyboard Maestro"
tell (first window whose subrole is "AXStandardWindow")
tell group 6
tell splitter group 1
tell scroll area 3
tell group 1
tell menu button 1
if exists of menu 1 then
tell menu 1
tell menu item "Set Note…"
return it
end tell
end tell
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
However there is no easy way to tell what the action is, unless it's selected. The trouble there is that a selected action can be detected by AppleScripting the Keyboard Maestro Editor, but that reference cannot be passed directly to System Events for UI-Scripting.
There is a method of detecting what menu is open using System Events and entire contents, but it's a kludge.
Keyboard Maestro does in fact have a selection object, but that doesn't help one bit in this case.
System Events? You can capture a click event and usually acquire a reference to the object clicked.
Correctly Identifying GUI Elements - #28 by CJK
Have fun.
-Chris