Skip to content

Instantly share code, notes, and snippets.

@seshness
Last active December 13, 2015 21:08
Show Gist options
  • Save seshness/4974492 to your computer and use it in GitHub Desktop.
Save seshness/4974492 to your computer and use it in GitHub Desktop.
Make your Caps Lock key a Control key
on caps_lock_to_control()
tell application "System Preferences"
tell application "System Events" to tell process "System Preferences" to tell window "Keyboard"
click pop up button "Caps Lock (⇪) Key:" of sheet 1
click menu item "⌃ Control" of menu 1 of pop up button "Caps Lock (⇪) Key:" of sheet 1
end tell
end tell
end caps_lock_to_control
tell application "System Preferences"
activate
reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
tell application "System Events" to tell process "System Preferences" to tell window "Keyboard"
click button "Modifier Keys…" of tab group 1
-- return entire contents of sheet 1
if pop up button "Select Keyboard:" of sheet 1 exists then
click pop up button "Select Keyboard:" of sheet 1
repeat with eachMenuItem in (get every menu item of menu 1 of pop up button "Select Keyboard:" of sheet 1)
click eachMenuItem
my caps_lock_to_control()
click pop up button "Select Keyboard:" of sheet 1
end repeat
click eachMenuItem
else
my caps_lock_to_control()
end if
click button "OK" of sheet 1
end tell
quit
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment