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?
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.
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.
Note that by default it will be triggered with Command+Return but you can change that, of course.
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)
I had been troubleshooting my Catalina one for a while with no luck.
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:
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:
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.
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.
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").
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"
Try it out. I would be interested to know how it works for you.
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.
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.
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)
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.
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)