Can AppleScript/osascript be used to click menu extra menu items?

0

1

I have an application installed that only appears in the menu bar (as a menu extra to the right). I would like to click one of the items contained in its menu via osascript. I've found the following code snippet:

osascript -e '
  tell application "System Events"
    tell process "SystemUIServer"
      tell (1st menu bar item of menu bar 1 whose value of attribute "AXDescription" is "keymando menu extra")
         perform action "AXPress" of menu item "Edit Config" of menu 1
      end tell
    end tell
  end tell

Sadly, it does not work. I assume I have the name of menu extra correct: "Keymando menu extra".

Jon Lorusso

Posted 2013-04-25T23:20:14.913

Reputation: 133

Answers

2

SystemUIServer only includes menu extras (the icons on the right side that can be rearranged) but not status menus (like the one Keymando uses).

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

In some applications menu bar 2 is the status menu, but tell application "System Events" to UI elements of process "Keymando" returns an empty list.

Lri

Posted 2013-04-25T23:20:14.913

Reputation: 34 501

Is there anyway to access those other status men items? – Jon Lorusso – 2013-04-26T13:57:33.193

THANK YOU! This just solved my HOURS long search on how to do this – Andrew Burns – 2014-04-11T16:23:47.613

1

I was able to open Hangouts with

tell application "System Events" to tell process "Google Chrome" to tell menu bar 2
    click (first menu bar item where help is "Google Hangouts")
end tell

w00t

Posted 2013-04-25T23:20:14.913

Reputation: 811

1

it may be in there, this will write a list in temp folder, that you can look through for a 'handle'.

`osascript -sso > /private/tmp/StatusBarItems <&- <<EOF
tell application "System Events"
    get properties of every  menu bar item of every menu bar  of process "SystemUIServer"
end tell
EOF`

or you can experiment with

   ` osascript -sso > /private/tmp/SU_reLoad <&- <<BUTTON
tell application "System Events"
    click  menu bar item 1 of menu bar 2 of application process "SystemUIServer"
end tell
BUTTON`

unfortunately the one I want isn't there... The 'exit full screen button' for a 'none scriptable' app... john

driven

Posted 2013-04-25T23:20:14.913

Reputation: 11