Toggling the Autohide Menu Bar Setting on macOS Big Sur

I have had KM macros for some time that allowed me to either toggle the autohide feature, or set it on or off. That feature was in the General preference pane. Now, with Big Sur, it moved to the Dock & Menu Bar preference pane. But, while one would expect the change to be trivial, it isn't. I cannot write an AppleScript that can find the checkbox "Automatically hide and show the menu bar". Any thoughts? I do have a workaround that it a complete hack however: Open up the pane and tab down 16 times to get to the checkbox. Really ugly. Any suggestions?

2 Likes

Dear lord I had no idea this was going to be so frustrating. I don't know if this is a Big Sur bug or what.

First I tried a defaults write followed by killall Finder but that left me with a completely inconsistent menu bar state which sometimes varied per app!

Then I thought I found the answer at https://jessicadeen.com/show-hide-menubar-big-sur/ but it did not work reliably. It worked sometimes. About 50% of the time. Maybe 75%. But not to an acceptable level.

“Oh well,” I thought, “I’ll just do a mouse click on the checkbox.”

Even that was unreliable, even though I had the coordinates spot-on. Keyboard Maestro would click, but the box wouldn't toggle.

Then I found that it would work System Preferences was NOT running, but if it was running, it wouldn't work.

Finally I realized that if I launched System Preferences, opened the right pane, clicked the right spot, and then opened another System Preference pane before quitting System Preferences, then it would work.

Why?

I have no bleeping clue.

Anyway, here's what I've come up with. If it works, great. If it doesn't, I'm sorry. I tried. Try prayer.

Toggle Menu Bar Visibility (Big Sur).kmmacros (35.2 KB)

Note that by default it will be triggered with Command+Return but you can change that, of course.

2 Likes

Yes, it’s a bug in the preference pane, and yes, I also spent a lot of time on this.

Here is a version that I believe works given the bugs I know about. It uses positional checkbox access for Big Sur, and an AppleScript for High Sierra:

AutoHide Menu Bar Toggle.kmmacros (16.4 KB)

1 Like

THANK YOU!

I had been troubleshooting my Catalina one for a while with no luck.

1 Like

You’re welcome.

2 Likes

Just a heads up for anyone trying the great Macro from Ikenassi. I had to adjust the mouse click positions a bit to work on my systems but was EZ PZ.

Here my solution under macOS Big Sur:

04)MB in:out <953D 201117T225623>.kmmacros (28,8 KB)

When executing an Apple script, I noticed that the window (Dock & Menu Bar) was not kept in the foreground during execution.
Therefore I always got an error message. If I insert a "tab" action (red arrow) in the KM macro, I prevent this @tjluoma.

The deactivated action (orange) is my AppleScript, which works fine under macOS Catalina.

Here are a few examples with my macro:

2020_11_17_Support_1

2 Likes

Good catch. Thanks. And thanks for the compliment.

Hi everyone, a few of you have reached out after I published my blog post with a "fix" for this, though the fix is currently blocked by the bug we all are experiencing. I just updated to macOS 11.1 Beta tonight and the bug is still current. I spent a lot of time investigating this, and while I do not have a better solution than those that have been presented here, I do have insight into what is actually happening. I recorded a short 5 minute video of the bug in action, which essentially boils down to Apple changing the Accessibility references for the System Preferences Pane, and specifically, the Dock & Menu Bar pane. Silly it worked well in the Beta and then broke in public release; even sillier they moved it from its location in Catalina thereby breaking all our previous scripts and macros.

2 Likes

Excellent illustration of this weird bug. No wonder I couldn't get it to work reliably -- although I'm still confused why clicking on it doesn't always work, but maybe it's because it's not really "there" sometimes, even when it's visible.

Anyway, here's hoping Apple fixes this one soonish.

@jldeen & @tjluoma I have a similar behavior with my AppleScripts for editing notifications (close, open, open menu etc.) under macOS Big Sur.

If you could directly address the buttons in the notification under macOS Catalina, this does not work anymore.
My AppleScripts will only work when the mouse cursor over the notification shows the buttons (here "X" and "View").

2020_11_18_Support_1

@jldeen, @tjluoma & @ikenassi, also me it does not leave any peace :wink:

I had already set up a KM macro above, which worked for me. Now I experimented a bit in AppleScript with the right pause between the "Tab Key" and the "Click Action" and... voilĂ , it works fluently for me now.

Here is my AppleScript:

tell application "System Preferences"
	reveal anchor "Dock" of pane id "com.apple.preference.dock"
	activate
end tell
tell application "System Events"
	tell process "System Preferences"
		key code "48"
		delay 1.5
		click checkbox 7 of window 1
	end tell
end tell
delay 0.6
quit application "System Preferences"

2020_11_18_Support_1

Try it out. I would be interested to know how it works for you.

1 Like

I was hopeful, but I still get the same error as before - it can't index to find the checkbox, likely because of the hierarchy I demonstrated in my video. :frowning:

1 Like

It is strange @jldeen, as shown in my gif, it still works for me without any problems.
I can repeat it as often as I want.

Shared with Droplr

1 Like

Your solution did not work for me.

I slightly modified mine which continues to work perfectly on Big Sur and High Sierra:

AutoHide Menu Bar Toggle.kmmacros (17.7 KB)

1 Like

Thanks @ikenassi for the feedback. It is really very strange. I am using a german macOS Big Sur, but that shouldn't make any difference with em AppleScript.

1 Like

Did you upgrade to the release or is this still an early Beta? The early beta worked fine, this issue seems to be in a recent update or the public release.

I am running the official standard please of Big Sur. 11.0.1.

I use the official version of macOS Big Sur @jldeen

Here is an update to my Auto Hide/Show Menu Bar Macros. These work in Light or Dark mode, and work on V. 11 and V. 10 MacOS. If you have other than an English version, you'll have to custom modify the Images used in the Find and Click Image Macro. Sorry about that. I could not see any way around it.

To do that, find the location of the center of the checkbox (shift-command-4) and select the square that has a 26 pixel border around it. In other words, select the top left corner of the rectangle and drag the cursor until you have a 52x52 square, and capture it, checked and unchecked, light and dark mode.

Auto HIde:Show Menubar.kmmacros (83.3 KB)

2 Likes