Does anyone have an AppleScript to toggle Bartender on/off? On being hide icons and off revealing all icons?
I would try adding a hotkey in Bartender, then using AppleScript to trigger that hotkey:
Is there a reason you’re not able/willing to use bartenders built in keyboard shortcuts? I know sometimes I want to use AppleScript to do something that could normally be triggered by a keyboard shortcut so I can implement it into a larger workflow task. But for simple things I find keyboard shortcuts work fine.
If you give us more info on what you’re trying to accomplish we might be able to help more.
I just want to toggle it on/off with a script because yes, it will be a part of a bigger workflow. Also, it’s Bartender 3, not 4.
I hear ya! Then the page Kevin Newman pointed out can probably help. You can basically have systems events trigger any key combo you want, therefore triggering whatever hot key you have to hide/show bartender menu bar items.
I did it, I wrote my first AppleScript that wasn’t simply copy, pasting and modifying someone else’s AppleScript.
tell application "Bartender"
activate
tell application "System Events" to key code 11 using {shift down, option down, control down, command down}
end tell
I’m not even sure I needed the tell application “Bartender” command.
Awesome! My AppleScript knowledge is very basic so I generally copy/paste and then modify haha.
Did this accomplish what you were looking to do?
On another (yet still related note), have you heard of Keyboard Maestro? One of it’s capabilities (among MANY) is sending key commands directly to applications without them having to be the active application. So it would allow you to implement sending this hot key directly to Bartender without having to deal with AppleScript (although many of KM’s features are really just AS commands but with a nice GUI overlay).
Yes, it did accomplish what I wanted it to do.
Yes, I love Keyboard Maestro but adding that script to my KM macro cut three actions from the workflow.
I was doing it via KM actions before replacing three actions with this AppleScript.
Awesome! Yea I implement a LOT of AS into my macros to have them run more efficiently and/or be more concise. Glad it worked out for you!