Sono stato in grado di modificare alcuni degli script già disponibili e farli funzionare in Lion. Per creare questi script:
- Esegui l'Editor di Applescript
- Crea due nuovi file di script vuoti (command-N)
- Incolla in questi due script
- salvali come "opzione comando di scambio" e "opzione comando ripristino" o qualsiasi altra cosa desideri
- Puoi testarli eseguendoli nell'editor di applescript.
Ecco lo script per scambiare il comando con l'opzione e l'opzione per il comando:
#
# Script to swap the Command and Option keys
# in the System Preferences Keyboard settings.
#
# Helpful if using a PC 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"
# Select keyboard: pop up button
click pop up button 5 of sheet 1 of window "Keyboard"
# The 4th choice there.. my USB Keyboard
click menu item 4 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"
click button "OK" of sheet 1 of window "Keyboard"
end tell
end tell
tell application "System Preferences"
quit
end tell
Ecco lo script per scambiarli:
#
# Script to restore the Command and Option keys to their defaults
# in the System Preferences Keyboard settings.
#
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"
# Select keyboard: pop up button
click pop up button 5 of sheet 1 of window "Keyboard"
# The 4th choice there.. my USB Keyboard
click menu item 4 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 Option, the 3rd choice
click menu item 3 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 Command, the 4th choice
click menu item 4 of menu 1 of pop up button 1 of sheet 1 of window "Keyboard"
click button "OK" of sheet 1 of window "Keyboard"
end tell
end tell
tell application "System Preferences"
quit
end tell
Per facilitare l'accesso a questi script, puoi andare su Preferenze di Applescript Editor e selezionare "Mostra menu Script nella barra dei menu". Quindi, copia gli script nella directory Libreria / Script della directory home, ovvero / Utenti / ryan / Libreria / Script
Ora puoi accedervi direttamente dal menu di script della barra dei menu.