Created
April 2, 2015 14:24
-
-
Save j05h/403148e8ec3c74fe7f7a to your computer and use it in GitHub Desktop.
AppleScript to change the keyboard modifier settings. Yosemite doesn't remember these settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# AppleScript to change the keyboard modifier settings. Yosemite doesn't remember these | |
# and reverts whenever you plug in a new keyboard. | |
# Options on the pane go from bottom to top of the window (at least in this case) | |
# If you use this, load it up in to Script Editor, run it. Assuming it works, | |
# Export to an application and save to the desktop. From there, you can execute | |
#x-help-script://com.apple.machelp/scpt/OpnPrefsBndID.scpt?com.apple.preference.keyboard | |
tell application "System Preferences" | |
activate | |
set current pane to pane "com.apple.preference.keyboard" | |
end tell | |
tell application "System Events" | |
tell process "System Preferences" | |
click button "Modifier Keys…" of tab group 1 of window "Keyboard" | |
try # Try allows us to only use this setting if a keyboard is plugged in | |
# Select keyboard: pop up button | |
click pop up button 5 of sheet 1 of window "Keyboard" | |
# The 2nd choice there.. my USB Keyboard, yours may be different | |
click menu item 2 of menu 1 of pop up button 5 of sheet 1 of window "Keyboard" | |
# The Option Key pop up | |
click pop up button 2 of sheet 1 of window "Keyboard" | |
# Change it to Command, the 4th choice | |
click menu item 4 of menu 1 of pop up button 2 of sheet 1 of window "Keyboard" | |
# The Command Key pop up | |
click pop up button 1 of sheet 1 of window "Keyboard" | |
# Change it to Option, the 3rd choice | |
click menu item 3 of menu 1 of pop up button 1 of sheet 1 of window "Keyboard" | |
end try | |
# I always want the Caps lock mapped to control | |
# The Caps Lock Key pop up | |
click pop up button 4 of sheet 1 of window "Keyboard" | |
# Change it to Control, the second choice | |
click menu item 2 of menu 1 of pop up button 4 of sheet 1 of window "Keyboard" | |
click button "OK" of sheet 1 of window "Keyboard" | |
end tell | |
end tell | |
quit application "System Preferences" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment