Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Applescript to click on a specific application in the Mac Status Bar

I have an OS X application that runs as a status bar app. I am trying to do a test automation. Is there a way to click the status bar app using Apple Script?

The script given below works only on native apps.

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

I am looking for a similar functionality on custom apps.

like image 943
Seema Kadavan Avatar asked Nov 01 '22 13:11

Seema Kadavan


1 Answers

Not all Menu Bar Extras (or status icons) can be accessed through UI Scripting. You have to experiment with whether they can be called through a unique description or other value. Play with code like this to see if you can figure it out:

tell application "System Events" to tell process "SystemUIServer"
    tell (menu bar item 1 of menu bar 1 where description is "clock")
        click
        click menu item "Open Date & Time Preferences…" of menu 1
    end tell
end tell

If you can't find it there, you can try menu bar 2 for Status items.

like image 54
jweaks Avatar answered Nov 11 '22 13:11

jweaks