

Set newKeyMap to item numDown of to paragraphs of (do shell script shellScript) If (ctrlVal contains "Command") then set numDown to 1 - for Control TOGGLE CONTROL KEY Between CONTROL & COMMAND KEY CODE. Repeat until (button "Modifier Keys…" of tab group 1) existsĬlick button "Modifier Keys…" of tab group 1 Set elapTime to my pauseUntilWin("Keyboard", "System Preferences", 1) Set elapTime to my pauseUntilWin("System Preferences", "System Preferences", 1)Ĭlick button "Keyboard" of scroll area 1 of window "System Preferences" Tell application "System Preferences" to activate Set frontApp to path to frontmost application as text Use AppleScript version "2.5" - macOS 10.11.6+ AppleScript UI Scripting of System Preferences (* If not, then I have some questions about UI scripting, but I’ll wait to hear from you guys first.

Is there an ASObjC or Shell Script method that will set the modifier keys directly, without using the UI? I have done extensive searching of the Internet, and have not found any. So, What is Best Method to Set System Preferences Modifier Keys? I’m not sure if it will work with Sierra.īut I hate using UI scripting, unless there is no alternative. I have written a proof-of-concept script below which uses the System Preferences UI, and it seems to work OK, at least in macOS 10.11.6. I have a colleague who needs to toggle the settings for Control and Command keys, basically switching them each time the script is run.
