I am trying to learn to access any menu item within an application with AppleScript. I can orient to the actual menu tab, and then access clickable menu items, but I can't access menu items within submenues that appear if they are hoovered over or RightArrow is pressed.
In the code below, "Zoom" is this type of menu item, and can't be found using the term 'menu item'. What term should I use instead so I can access "Zoom in"?
1 tell application "Firefox"
2 activate
3 tell application "System Events"
4 tell process "Firefox"
5 click menu item "Zoom in" of menu item "Zoom" of menu "Tools" of menu bar 1
6 end tell
7 end tell
8 end tell
Note: "Zoom in" has, by chance, a shortcut "CMD" and "+", but this is not a solution.
Additional question: How do I pick "the first", "the last" or the "n:th" menu item?
Best Answer
There are a couple of things.
First you will need a delay between the Activation of the App (Firefox) and the click action.
If you do not,the click action will be fire way too soon for the application to pick it up.
Secondly, in my FirfFox the Zoom in Menu item is under the View menu.
So the code needs to work back from the Zoom in menu item back to the initial Menu item taking in all the nodes in between.
click menu item "Zoom In" of menu 1 of menu item "Zoom" of menu 1 of menu bar item "View" of menu bar
1Each Sub menu item must have a controlling menu
So you could even use.