How to autohide the menubar

I’m looking for a script to toggle the autohide option for the menubar without dealing with preferences files and killing processes.

I found a hint here https://stackoverflow.com/a/33024418/4071750, but how do I translate it to AppleScript?

Stuff like “get current application’s presentationOptions” gives me an error.

Try this:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use scripting additions

-- classes, constants, and enums used
property NSApplicationPresentationAutoHideDock : a reference to 1
property NSApplicationPresentationAutoHideMenuBar : a reference to 4

current application's NSApp's setPresentationOptions:(NSApplicationPresentationAutoHideMenuBar + NSApplicationPresentationAutoHideDock)


1 Like

Thank you very much. That works. Is this the correct way to show Dock and Menubar again: setPresentationOptions:(0)

Pretty much. You could use NSApplicationPresentationDefault, which has a value of 0, if you wanted to make the intent of the code clearer.

1 Like