Handling Menu Bar Items + Bartender + Applescripts

I have been using Bartender to hide meni bar items for years, def one of the first things I install on all my macs, but I have found myself working on a MacBook Air alot so with a much smaller screen even with bartender sometimes I feel like the menu bar is too cluttered on such a small screen.

I have Macros & apple scripts setup for interacting with many of my menu bar items. When they are visible the scripts work great but if the items are marked as hidden eh scripts don't work (obviously)

Right now my workaround is building a macro with the first action being typing the bartender hotkey that shows the midden menubar bar items, pause for .35 seconds, and then executing the scripts.

Does anyone have a more efficient way to do this? Bless all the devs who include both

  1. Hide from Dock
  2. System-wide Hot Key (That you can change)

Also, has there been any progress made on eliminating the delay in GUI scripting if firing a script from KM? The 3 to 4-second delay isn't awful but if it could be eliminated while executing the script from KM that would be awesome.

Hello @Brian_Martin, I use a GUI script to call the menu bar items under the Bartender app and have no noticeable differences in execution.

Here is an example without the Bartender App:

and now with Bartender App:

Here is the script for it:

tell application "System Events"
   tell application process "Yoink"
      tell menu bar 1
         tell menu bar item 1
               with timeout of 0.1 seconds
                  perform action "AXPress"
               end timeout
            end try
         end tell
      end tell
   end tell
end tell
do shell script "killall 'System Events'"
tell application "System Events"
   repeat 3 times
      key code 125
   end repeat
   key code 36
end tell

Sorry I'm not sure I follow.

The script above calls the app Yoink weather its hidden by bartender or not?

I've tried swapping it out with a few mini bar items I Use and have had no luck.

Yes, that is correct @Brian_Martin.

Could you tell me a few apps you would open with the script?
It is also important that you have these two entries in the security settings:

Hey Sorry I forgot to reply.

So I do have both of those items checked and for example this script has been working for me for a few years now.

tell application "System Events" to quit
tell application "System Events" to tell process "Private Internet Access"
   click menu bar item 1 of menu bar 2
end tell
do shell script "killall System\\ Events"
delay 0.1
tell application "System Events" to tell process "Private Internet Access"
   tell menu bar item 1 of menu bar 2
      key code 48
      key code 36
   end tell
end tell

I have tried your script swapping out "Yoinks" with
Private Internet Access

All of those work with my script but only when they are visible via bartender.

1 Like

Hi @Brian_Martin, please excuse me. I made a mistake with the script. I forgot to tell you that you have to try the apps to see if they work with a 1 or 2 (here red arrow).

MacUpdater <64BF 200904T202519>

For the MacUpdater app, there must be a 2.
I myself don't have the App MacUpdater running in the background, but call it manually every few days (here Launchbar 6 with a KM macro).

In my example first Bartender is disabled and you can see how the AppleScript and the KM macro work.

Then I activated Bartender and the KM macro is executed in the background without the MacUpdater item being visible in the foreground.

Please try the macro with and without bartender.

MacUpdater <64BF 200904T202519>.kmmacros (29,9 KB)