Scripting right end menu bar menus

I’ve been looking for a way to reach a submenu of a menu bar dropdown that doesn’t show up in UI Browser. Is that even possible?

Adam:

Not that I’m any good at UI scripting to begin with, but I got nowhere either. I assume you got at least this far:


tell application "System Events"
	tell application process "SystemUIServer"
		
		click menu bar item 1 of menu bar 1
		
	end tell
end tell

… but trying to add other elements (by guess or by golly) doesn’t to work.

No help.

Peter B.


I noticed UI Browser doesn’t immediately recognize some sub-menu items in my Applescript menu extra. This is when using the screen reader capability. However if I move my mouse to the far right or far left of the non-recognizable menu item then it does get recognized in screen reader… and I can programmatically click it. Here’s the script I used to test that. Notice all of the “of menu 1” parts it includes. Maybe this will help you???

tell application "System Events"
	tell application process "SystemUIServer"
		tell menu bar 1
			click menu bar item 2
			tell menu bar item 2
				click menu item "Movies" of menu 1
				tell menu item "Movies" of menu 1
					click menu item "Search IMDB" of menu 1
				end tell
			end tell
		end tell
	end tell
end tell

Thank you for that – it did get me going. For example, I observe that menu bar extras are counted from the right to left with language being #1, so clicking on menu bar item 5 (on my Leopard machine) drops the bluetooth menu. This much works, but I can’t delve into the submenu below that.

tell application "System Events"
	tell application process "SystemUIServer"
		tell menu bar 1
			click menu bar item 5
			tell menu bar item 5
				click menu item 8 of menu 1
				-----
			end tell
		end tell
	end tell
end tell