0
votes

I'd like to AppleScript to click a menu bar icon (not a system process) and then click on one of the menu items. I'm using OS X 10.10.

I've read that I can use the Accessibility Inspector to find the AXDescription of the item, however, I can't find it anywhere in the inspector (in fact none of the items I inspected seemed to have this property).

Accessibility Inspector

I also tried the method described here but get an error on line 10:

ignoring application responses
    tell application "System Events" to tell process "Webcam Settings"
        click menu bar item 1 of menu bar 2
    end tell
end ignoring
do shell script "killall System\\ Events"
delay 0.1
tell application "System Events" to tell process "Webcam Settings"
    tell menu bar item 1 of menu bar 2
        click menu item "Show Webcam Settings Panel" of menu 1
    end tell
end tell

 System Events got an error: Can’t get menu 1 of menu bar item 1 of menu bar 2 of process "Webcam Settings". Invalid index.
1
Your path simply is wrong, then. Show a screen shot of your app open to that menu item. Is the locked Accessibility Inspector above showing the menu or the menu item. Are you sure it's menu bar 2?jweaks
Can you explain what you mean by path name? The AI in the screenshot it locked the to menu bar item (icon). Here is a screenshot of AI locked to the menu item cl.ly/image/1B053O2P2D3H How do I know if it's menu bar 1 or 2?Sebastien
Ok, you aren't accessing a standard menu, but rather a utility icon menu over on the right side of the menu bar. And part of the problem may be that this is a 'faceless' app. Does it appear in the Dock? Can its "frontmost" be set to "True"? Otherwise, System Events may not be able to access its menu items.jweaks

1 Answers

0
votes

There are some menu bar apps which you can click and show menu with applescript regardless of if they appear in dock. But I am afraid you can’t access the menubar of “Webcam Settings” with applescript. Because there isn’t key named “isAccessbiliyFocused” in the attributes. Menu bar apps you can show their menu with applescript have that key and its value is “Yes”. I am not quite sure about my answer but as far as I investigate this issue, my answer is probably right.