Re: Menulet scripting
Re: Menulet scripting
- Subject: Re: Menulet scripting
- From: David Gregg <email@hidden>
- Date: Tue, 27 Jun 2017 07:51:54 -0600
Bob,
Sorry, the example should have read the following for the one that correctly
implements the menu system. After reading the latest from Bill, I went back and
noticed I had left off the menu bar parent in the call.
tell application "System Events"
tell process "exaSoundDashboard"
click menu item "Settings" of menu 1 of menu bar item 1 of menu
bar 1
end tell
end tell
David
On Jun 27, 2017, at 7:37 AM, David Gregg <email@hidden> wrote:
Bob,
On Jun 27, 2017, at 5:24 AM, Bob Stern <email@hidden> wrote:
Thanks Bill, David and Naganoya-san. (Bill: I'm running El Capitan.)
The menulet is displayed by an otherwise faceless background application whose
function is to control configuration parameters of an audio output hardware
device (D/A converter). The application communicates with the hardware device
through a kernel extension installed along with the faceless application.
The menu extra has 5 menu items. The first 2 menu items have sub-menus:
<Screen Shot 2017-06-27 at 4.20.34 AM.png>
I cannot access any of the menu items by index number because AppleScript
reports the menu extra as having only one menu bar item:
tell application "System Events"
tell menu bar 1 of process "exaSoundDashboard"
count menu bar items -- returns count = 1.
end tell
end tell
This should only return a count of 1 because you are asking System Events how
many menu bar items are associated with the process of exaSoundDashboard.
Curiously, a tell directed to menu bar 2 produces the error "Can’t get menu bar
2 ..." Contrary to OS X menu extras, this application's menu extra is menu bar
1.
Likely suggesting that this menulet uses menu bar 1 and confirmed by you
further down.
If I replace the count command with "click menu bar item 1", the menu does drop
down. However, I cannot click any of the menu items. I get an error that menu
bar item 2 or 3 does not exist when I do the following, with or without the
preceding line commented out:
tell application "System Events"
tell menu bar 1 of process "exaSoundDashboard"
-- click menu bar item 1
click menu bar item 2 -- Error if number is 2, 3, etc.
end tell
end tell
Clicking by position does nothing:
tell application "System Events"
tell menu bar 1 of process "exaSoundDashboard"
click menu bar item 1 -- menu drops down.
click at {859, 80} -- no menu item is clicked.
end tell
end tell
Same result:
tell application "System Events"
tell menu bar item 1 of menu bar 1 of process "exaSoundDashboard"
click at {859, 80} -- menu drops down but no menu item is
clicked.
end tell
end tell
You have the menu dropping which is good. Now you need to figure out how to
trigger a menu item or submenu item.
Which menu items or submenu items are you wanting to trigger?
Using your image as a model and attempting to trigger the "Settings" menu item
might look like this, if it works directly with the menu system.
tell application "System Events"
tell process "exaSoundDashboard"
click menu item "Settings" of menu 1 of menu bar item 1
end tell
end tell
if it doesn't work directly with the menu system, then you might have to use
something like this...
tell application "System Events"
tell process "exaSoundDashboard"
click menu bar item 1
delay 0.2
keystroke "Settings" & return
end tell
end tell
You might also have to play with the delay amount. If that doesn't work then
try something like "delay 2" to see whether it is the delay time that is
causing the problem.
If you are interested in triggering submenus within the "Mode" or "DAC Input"
menus then you will need to let me know the names of the submenus.
David
If there's no solution, I can try begging the manufacturer to add keyboard
shortcuts, a window interface that can be scripted, or a CLI. :)
Bob Stern
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden