Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Changing Keyboard Modifier Keys

I use an external Windows keyboard on my PowerBook while at work, then use the internal keyboard at home. To keep from hitting the wrong keys all day, I open the sys prefs each morning and swap the Option and Command keys (Alt and Windows keys on the external keyboard), then swap them back each night at home. While this is easy enough to do, I'd like an AppleScript or Automator Task that can do this for me. Since I'm a novice when it comes to Automator and scripting, can anyone help me with this?

Thanks!

PowerBook G4 17 1.67GHz Mac OS X (10.4.6) Dell Windows External Keyboard (ugh!)

Posted on Apr 6, 2006 8:05 AM

Reply
3 replies

Apr 12, 2006 10:34 AM in response to Randy Farnsworth

I solved this problem by finding and altering an applescript that will change the keyboard modifier keys. I wish I could still find the web page so I could post it, but here's the applescript I used to change to PC layout:

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 radio button "Keyboard" of tab group 1 of window "Keyboard & Mouse"
click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"

click pop up button 3 of sheet 1 of window "Keyboard & Mouse"
click menu item 4 of menu 1 of pop up button 3 of sheet 1 of window "Keyboard & Mouse"
delay 1
click pop up button 4 of sheet 1 of window "Keyboard & Mouse"
click menu item 3 of menu 1 of pop up button 4 of sheet 1 of window "Keyboard & Mouse"
click button "OK" of sheet 1 of window "Keyboard & Mouse"
end tell
end tell

tell application "System Preferences"
quit
end tell

(end of script)

And here's the script I used to change it back to Mac layout:

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 radio button "Keyboard" of tab group 1 of window "Keyboard & Mouse"
click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"
click button "Restore Defaults" of sheet 1 of window "Keyboard & Mouse"
click button "OK" of sheet 1 of window "Keyboard & Mouse"
end tell
end tell

tell application "System Preferences"
quit
end tell

(end of script)

I saved the scripts as executibles with neat Apple and XP custom icons and put them in the Dock. Pretty slick.

Changing Keyboard Modifier Keys

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.