J'ai pu modifier certains des scripts déjà existants, et les faire fonctionner dans Lion. Pour créer ces scripts :
- Lancer l'éditeur Applescript
- Créer deux nouveaux fichiers script vides (commande-N)
- Collez les deux scripts suivants
- Enregistrez-les sous un nom tel que "option de commande d'échange" et "option de commande de restauration" ou ce que vous voulez.
- Vous pouvez les tester en les exécutant dans l'éditeur applescript.
Voici le script pour permuter commande vers option, et option vers commande :
#
# 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
Voici le script pour les échanger à nouveau :
#
# 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
Pour rendre ces scripts faciles d'accès, vous pouvez aller dans les préférences de l'éditeur Applescript et cocher "Afficher le menu scripts dans la barre de menu". Ensuite, copiez vos scripts dans votre répertoire personnel Library/scripts, c'est-à-dire /Users/ryan/Library/scripts.
Vous pouvez maintenant y accéder directement depuis le menu script de la barre de menu.