Можно ли использовать AppleScript / osascript для выбора дополнительных пунктов меню?

4351
Jon Lorusso

У меня установлено приложение, которое отображается только в строке меню (как дополнительное меню справа). Я хотел бы щелкнуть один из пунктов, содержащихся в его меню, через osascript. Я нашел следующий фрагмент кода:

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 

К сожалению, это не работает. Я предполагаю, что у меня есть правильное название меню: "Keymando menu extra".

0

3 ответа на вопрос

1
user495470

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.

Есть ли какой-либо доступ к этим другим элементам статуса? Jon Lorusso 11 лет назад 0
БЛАГОДАРЮ ВАС! Это просто решило мои ЧАСЫ долгих поисков, как это сделать Andrew Burns 10 лет назад 0
1
driven

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

0
w00t

Мне удалось открыть видеовстречу с

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