AppleScript Access Menu Items in Top Bar

Trying to find out how to click on third party icons on the top Apple Menu bar, just tried this applescript and it worked!

However, when I test with the following actions of down/left arrows it take around 6 seconds after dropdown for the arrows to work - I think the delay is in the applescript but having looked on the web none the wiser. Can anybody point me at a possible solution?

Screen Shot 2021-08-03 at 21.13.29

@michael_gilbert please try this AppleScript:

    tell application "System Events"
	tell application process "Default Folder X"
		tell menu bar 2
			tell menu bar item 1
				try
					with timeout of 0.1 seconds
						perform action "AXPress"
					end timeout
				end try
			end tell
		end tell
	end tell
end tell
do shell script "killall 'System Events'"
tell application "System Events"
	repeat 6 times
		key code 125
	end repeat
	key code 124
end tell

That is amazing! Can you tell me where I can lookup the key codes as am assuming they correspond to arrows so I can amend for refining selected submenus.?

Brilliant - can go to bed now.

Thank you sooo much.

1 Like

Here is one source.

2 Likes

Great - thank you.

You're welcome.

@michael_gilbert here is the website for it:

Then have fun calling it from the menubar.
If you use an app like Bartender, the AppleScript will run in the background.

2021_08_04_Support_1