Since sometimes I’m awfully lazy - I got myself a second keyboard, just for the sake of not having to carry one to office and back. At home I use my beloved Apple Keyboard, while at work - a crappy, no-name, ten-bucks-a-piece one (it does it job, though!).
However, since at work I use a Windows keyboard I had a problem with the switched Option / Command keys. I’ve tried DoubleCommand, however I had to click through the System Preferences each time I switched my keyboard. Couple of minutes of googling and a nice script popped out. However, it was useless in OS X Leopard, so I made a couple of quick changes and here’s something I came up with. First, switch-to-windows-keyboard script:
tell application "System Preferences" activate set current pane to pane "com.apple.preference.keyboard" end tell tell application "System Events" get properties tell process "System Preferences" click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse" click pop up button 2 of sheet 1 of window "Keyboard & Mouse" delay 0.3 click menu item 4 of menu 1 of pop up button 2 of sheet 1 of window "Keyboard & Mouse" delay 0.3 click pop up button 1 of sheet 1 of window "Keyboard & Mouse" delay 0.3 click menu item 3 of menu 1 of pop up button 1 of sheet 1 of window "Keyboard & Mouse" delay 0.3 click button "OK" of sheet 1 of window "Keyboard & Mouse" end tell end tell tell application "System Preferences" quit end tell
Second, back-to-apple-keyboard script:
tell application "System Preferences" activate set current pane to pane "com.apple.preference.keyboard" end tell tell application "System Events" get properties tell process "System Preferences" 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
You might ask why not use Ryan Block’s script? Well, since I rely heavily on QuickSilver I also created two Platypus applications - one for each script. I’m a keyboard user, so I didn’t like the clicking on the Macintosh / PC screen. ;-]