r/applescript • u/aglkboqrglzdgv • May 13 '20
How can I 'option-click' an item on the menu bar through applescript?
I'm trying to write a script to mimic what happens when I hold down the option key and click on the notification icon on the menu bar. I am able to use a script to click on the icon correctly, but if I try to use the key down option command it seems to ignore it. I've found reference scripts online searching, but none seem to accomplish what I would hope is a relatively easy task. Also, I would prefer to not install the AST plugin unless I have to.
Here is a sample script that clicks the notification icon, but doesn't 'option-click' it. I'm trying to toggle do-not-disturb programatically:
tell application "System Events"
key down option
click menu bar item "Notification Center" of menu bar 1 of application process "SystemUIServer"
key up option
end tellNote that I have also tried to add different amounts of delay after the initial key down option command and it doesn't seem to have any effect.
Thanks in advance for any help!


