How can I get a list of menu items using Applescript?

Is there a way to get a list of all menu items under a menu heading, such as File or Edit , using AppleScript?

I found some related questions, but nothing precise. Google is also out of luck.

I am trying to get a list of files open in the Photoshop Window menu and find out which one is checked.

screenshot-with-shadow.png

I think I can complete the second part using something like " In Applescript, how can I find out if a menu item is selected / is it highlighted? " And Accessibility Inspector, since it has AXMenuItemMarkChar

screenshot-with-shadow.png

+8
source share
1 answer

I don't have Photoshop, but this works for Illustrator:

 activate application "Adobe Illustrator" tell application "System Events" tell process "Adobe Illustrator CS5.1" set xxx to name of every menu item of menu 1 of menu bar item "Window" of menu bar 1 end tell end tell 

To get the attribute, you can use:

 activate application "Adobe Illustrator" tell application "System Events" tell process "Adobe Illustrator CS5.1" set xxx to value of attribute "AXMenuItemMarkChar" of menu item "tools" of menu 1 of menu bar item "Window" of menu bar 1 end tell end tell 

nil:

 activate application "Adobe Illustrator" tell application "System Events" tell process "Adobe Illustrator CS5.1" set xxx to value of attribute "AXMenuItemMarkChar" of menu item "Brushes" of menu 1 of menu bar item "Window" of menu bar 1 try xxx on error -- insert your code beep 2 end try end tell end tell 
+10
source

All Articles