I have an app called Fenêtre, when looking process name using top
command it gives the name Fene?~Btre H
.
I would like to click the item called 'a.py' under its menubar item as shown in figure.
My attempt:
attempt 1
tell application "System Events" to tell process "Fenêtre"
tell menu bar item 1 of menu bar 1
click
click menu item "Show all" of menu 1
end tell
end tell
Error:
$ osascript a.applescript
a.applescript:121:157: execution error: System Events got an error: Can’t get menu item "Show all" of menu 1 of menu bar item 1 of menu bar 1 of process "Fenêtre". (-1728)
Note that, when I run only first and last line of attemp1 it runs good, when I add middle lines it fails to run.
attempt 2
ignoring application responses
tell application "System Events" to tell process "Fenêtre"
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 "Fenêtre"
tell menu bar item 1 of menu bar 2
click menu item "a.py" of menu 1
-- click menu item 1 of menu 1 -- another try
end tell
end tell
Updates (Still get errors)
tell application "System Events" to tell process "Fenêtre"
get entire contents of menu bar 2
end tell
This gives:
{menu bar item 1 of menu bar 2 of application process "Fenêtre" of application "System Events"}
References:
Applescript: on clicking Menu Bar item via gui script
applescript click menu bar option
https://superuser.com/questions/587815/can-applescript-osascript-be-used-to-click-menu-extra-menu-items
Applescript to show Apple menu bar items
Is AppleScript UI Scripting very slow in general, or is it my script, or something else?
Clicking an applications menu bar item with AppleScript
Thanks a lot.
menu bar 2
, notmenu bar 1
. However, for the app I was testing, there were no contents of that menu bar item visible to the Accessibility system (which is what System Events uses to access the UI). I don't know if that's particular to the app I was testing or general for all menu bar apps. What do you get fromget entire contents of menu bar 2
? – Ken Thomasestell application "System Events" to tell process "Fenêtre" get entire contents of menu bar 2 end tell
gives{menu bar item 1 of menu bar 2 of application process "Fenêtre" of application "System Events"}
– user8864088tell application "System Events" tell (first application process whose bundle identifier is "com.yoannmoinet.fenetre") get entire contents of menu bar 2 end tell end tell
gives the same thing{menu bar item 1 of menu bar 2 of application process "Fenêtre" of application "System Events"}
– user8864088click
command on the menu bar item does cause it to open, but the command doesn't complete until the menu is dismissed, so you can't issue subsequent commands to find out. It may work to usetry
andwith timeout
to get control back while the menu is still up. – Ken Thomases