Skip to content

Instantly share code, notes, and snippets.

@pbojinov
Created August 10, 2015 19:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbojinov/4afe4c7526df40b21bd5 to your computer and use it in GitHub Desktop.
Save pbojinov/4afe4c7526df40b21bd5 to your computer and use it in GitHub Desktop.
OSX Automator script to toggle hot corners on/off with some predefined defaults. Particularly useful when playing games and need to turn off hot corner actions quickly and restore to default after.
property theSavedValues : {"Application Windows", "Mission Control", "Desktop", "Notification Center"} -- for example
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.expose"
tell application "System Events"
tell window "Mission Control" of process "System Preferences"
click button "Hot Corners…"
tell sheet 1
tell group 1
set theCurrentValues to value of pop up buttons
if theCurrentValues is {"-", "-", "-", "-"} then
repeat with i from 1 to 4
set thisValue to item i of theSavedValues
tell pop up button i
click
click menu item thisValue of menu 1
end tell
end repeat
else
copy theCurrentValues to theSavedValues
repeat with i from 1 to 4
tell pop up button i
click
click last menu item of menu 1
end tell
end repeat
end if
end tell
click button "OK"
end tell
end tell
end tell
quit
end tell
@besil
Copy link

besil commented Oct 24, 2022

if you get System Events got an error: Can’t get window "Mission Control" of process "System Preferences"., just add "delay 0.5" after 'tell application "System events"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment