Reputation: 31
I am trying to write an applescript to hide the menubar in fullscreen when i watch movies. Otherwise i want it always turned on. I have come so far as to reveal the tab "Dock & Menu Bar" but i don't know how to click the right checkbox. The following code is what i have come up with but as stated it isn't much.
tell application "System Preferences" activate set the current pane to pane id "com.apple.preference.dock" end tell
For reference: I want to click the checkbox "Automaticly hide and show the menu bar in full screen"
Upvotes: 2
Views: 1303
Reputation: 502
I've made a script to do this, feel free to extend the automation to your needs:
-- # Check to see if System Preferences is
-- # running and if yes, then close it.
if running of application "System Settings" then
try
tell application "System Settings" to quit
on error
do shell script "killall 'System Preferences'"
end try
delay 0.1
end if
-- # Make sure System Preferences is not running before
-- # opening it again. Otherwise there can be an issue
-- # when trying to reopen it while it's actually closing.
repeat while running of application "System Settings" is true
delay 0.1
end repeat
-- # Open to Dock & Menu Bar
do shell script "open -j x-apple.systempreferences:com.apple.ControlCenter-Settings.extension"
set ALWAYS to "Always"
set ON_DESKTOP_ONLY to "On Desktop Only"
set IN_FULL_SCREEN_ONLY to "In Full Screen Only"
set NEVER to "Never"
tell application "System Events"
tell application process "System Settings"
repeat until exists (pop up button 1 of group 9 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Control Center")
delay 0.2
end repeat
tell pop up button 1 of group 9 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Control Center"
click
click menu item IN_FULL_SCREEN_ONLY of menu 1
end tell
end tell
end tell
delay 0.5
tell application "System Settings" to quit
And also made a shortcuts automation here
Upvotes: 2
Reputation: 3142
When any application is in "Full Screen Mode", the menu bar is automatically hidden. However, if the app is "Zoomed", this following AppleScript code will toggle the autohide menu bar to on or off.
tell application "System Events"
if not autohide menu bar of dock preferences then
set autohide menu bar of dock preferences to true
else
set autohide menu bar of dock preferences to false
end if
end tell
Upvotes: 0