
Of course, if you didn’t want to use Stream Deck or Keyboard Maestro, you could just save the script, and create a function, and call said function from command line, examples of this are below. Now, you may wonder, how do I use this with something like StreamDeck? Easy! I use this Keyboard Maestro Integration, create the macro in Keyboard Maestro and reference it in Stream Deck. The revised code, as you’ll notice below, keeps System Preferences hidden in the background while the menu bar is toggled, then quits the application once the toggle is complete.Īs an added bonus, I found this blog post helpful for determining the pane id for the window you care about.
#Applescript script keyboard maestro code
Prior to finding this, the code worked well, but would error the first time you ran it (since it didn’t have the “Main” anchor selected), and then it would succeed subsequent times as long as System Preferences was open in the background. After I upgraded to macOS 11 Big Sur, I noticed several of my hotkeys / functions stopped working since Big Sur moved where things like the menu bar enable / disable check box is.Īfter spending a little bit of time playing with it, I came up with the below AppleScript code that will allow me to quickly and easily show or hide my menu bar.įull disclosure, I did use this stackexchange article to figure out the last piece of the puzzle, which ensures the “Main” anchor of the necessary pane is in fact selected, prior to clicking the necessary UI element.

One key task I use frequently, especially when recording videos, is the ability to quickly and easily hide my menu bar.

If you know me, you probably know I’m a huge fan of “no clicky clicky,” which pretty much means - I want to click as little as possible on my screen to accomplish simple, or even complex, tasks.įor my day to day workflow I use a Stream Deck and a program called Keyboard Maestro to help me accomplish automations that are important to me. Tell application "System Events" tell dock preferences to set autohide menu bar to not autohide menu bar end tell Star 19 Code Issues Pull requests AppleScript Surge Keyboard Maestro jxa applescript surge keyboard-maestro Updated on emraher / workflow Star 33 Code Issues Pull requests Scripts, codes, extensions, macros, etc.
