Cómo cambiar las teclas de modificador de command y opción con un script en OS X Lion

Utilizo un keyboard usb de PC con mi macbook. Por lo tanto, he entrado en System Preferences > Keyboard > Modifier Keys … y el command y la opción swapped para el keyboard usb. Esto pone esas llaves en la position "correcta" para un mac.

Pero, durante parte del día, el escritorio remoto a una máquina de windows. Así que ahora, tengo que cambiar las teclas de nuevo, por lo que el cliente de escritorio remoto no está confundido.

  • ¿Cómo puedo ejecutar una secuencia de commands de shell que solicita la input de usuario desde Applescript
  • Automatización de ffmpeg mediante el service Automator
  • Necesita una secuencia de commands para exportar automáticamente PDF de Skim con notas incrustadas
  • Batch comprimir varias carpetas en files zip individuales
  • Error de barra de progreso de AppleScript: ¿Cómo evitar que se detenga el dialog de progreso?
  • Cualquier manera de establecer / añadir tags en un file con Applescript bajo Mavericks?
  • Es bastante fácil hacer esto a través de la interfaz de usuario de Preferences , pero es engorroso.

    Me gustaría usar un script de algún tipo (quizás applescript), así que podría cambiar rápidamente de ida y vuelta.

    He encontrado varias secuencias de commands en línea, pero ninguna de ellas es para Lion.

  • Automatizar la toma de una captura de pantalla del área especificada
  • ¿Hay una manera de alternar entre las windows de pantalla completa en OS X?
  • Hacer que la window activa sea más obvia en OSX
  • ¿Cómo puedo ver cuánto time ha estado activo mi equipo (como si no estuviera inactivo)
  • ¿Cómo acceder a los icons de la barra de menus instalados por el usuario con el keyboard?
  • Guarde los files adjuntos de Mail.app en function del asunto
  • 2 Solutions collect form web for “Cómo cambiar las teclas de modificador de command y opción con un script en OS X Lion”

    Pude modificar algunos de los guiones ya existentes, y conseguir que funcionen en Lion. Para crear estos scripts:

    • Ejecutar el Editor de Applescript
    • Crear dos nuevos files de secuencia de commands vacíos (command-N)
    • Pegar en estos dos scripts
    • Guardarlos como algo como "opción de command de intercambio" y "opción de command de restauración" o lo que quieras
    • Puede probarlos ejecutándolos en el editor de applescript.

    Aquí está el script para cambiar el command a la opción, y la opción al command:

     # # 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 # # # 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 # # # 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 # # # 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 decir # # 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 decir # # 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 decir # # 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 

    Aquí está el script para intercambiarlos:

     # # Script to restre 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 # # # Script to restre 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 # # # Script to restre 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 decir # # Script to restre 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 decir # # Script to restre 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 decir # # Script to restre 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 

    Para que estos scripts sean fáciles de acceder, puede ir a Preferences del Editor de Applescript y marque "Mostrar el menu de Script en la barra de menu". A continuación, copie los scripts en el directory de su biblioteca de inicio / Scripts, es decir, / Users / ryan / Library / Scripts

    Ahora puede acceder directamente desde el menu de la barra de menus.

    También puede usar un private.xml como este con KeyRemap4MacBook:

     <?xml version="1.0"?> <root> <item> <name>test</name> <identifier>test</identifier> <not>REMOTEDESKTOPCONNECTION</not> <autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen> <autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen> </item> </root> <? xml version = "1.0"?> <?xml version="1.0"?> <root> <item> <name>test</name> <identifier>test</identifier> <not>REMOTEDESKTOPCONNECTION</not> <autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen> <autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen> </item> </root> <item> <?xml version="1.0"?> <root> <item> <name>test</name> <identifier>test</identifier> <not>REMOTEDESKTOPCONNECTION</not> <autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen> <autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen> </item> </root> </ item> <?xml version="1.0"?> <root> <item> <name>test</name> <identifier>test</identifier> <not>REMOTEDESKTOPCONNECTION</not> <autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen> <autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen> </item> </root> 

    REMOTEDESKTOPCONNECTION se define en appdef.xml .

    Esto haría que la opción y el command swapping de conmutación de fn-escape:

     <?xml version="1.0"?> <root> <item> <name>test</name> <identifier>test</identifier> <autogen>__KeyToKey__ KeyCode::ESCAPE, ModifierFlag::FN, KeyCode::VK_CONFIG_TOGGLE_swapoptcmd</autogen> </item> <item> <name>swapoptcmd</name> <identifier vk_config="true">swapoptcmd</identifier> <autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen> <autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen> </item> </root> <? xml version = "1.0"?> <?xml version="1.0"?> <root> <item> <name>test</name> <identifier>test</identifier> <autogen>__KeyToKey__ KeyCode::ESCAPE, ModifierFlag::FN, KeyCode::VK_CONFIG_TOGGLE_swapoptcmd</autogen> </item> <item> <name>swapoptcmd</name> <identifier vk_config="true">swapoptcmd</identifier> <autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen> <autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen> </item> </root> <item> <?xml version="1.0"?> <root> <item> <name>test</name> <identifier>test</identifier> <autogen>__KeyToKey__ KeyCode::ESCAPE, ModifierFlag::FN, KeyCode::VK_CONFIG_TOGGLE_swapoptcmd</autogen> </item> <item> <name>swapoptcmd</name> <identifier vk_config="true">swapoptcmd</identifier> <autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen> <autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen> </item> </root> </ item> <?xml version="1.0"?> <root> <item> <name>test</name> <identifier>test</identifier> <autogen>__KeyToKey__ KeyCode::ESCAPE, ModifierFlag::FN, KeyCode::VK_CONFIG_TOGGLE_swapoptcmd</autogen> </item> <item> <name>swapoptcmd</name> <identifier vk_config="true">swapoptcmd</identifier> <autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen> <autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen> </item> </root> <item> <?xml version="1.0"?> <root> <item> <name>test</name> <identifier>test</identifier> <autogen>__KeyToKey__ KeyCode::ESCAPE, ModifierFlag::FN, KeyCode::VK_CONFIG_TOGGLE_swapoptcmd</autogen> </item> <item> <name>swapoptcmd</name> <identifier vk_config="true">swapoptcmd</identifier> <autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen> <autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen> </item> </root> </ item> <?xml version="1.0"?> <root> <item> <name>test</name> <identifier>test</identifier> <autogen>__KeyToKey__ KeyCode::ESCAPE, ModifierFlag::FN, KeyCode::VK_CONFIG_TOGGLE_swapoptcmd</autogen> </item> <item> <name>swapoptcmd</name> <identifier vk_config="true">swapoptcmd</identifier> <autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen> <autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen> <autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen> </item> </root> 
    Loving Apple Products like poisoning (iPhone, iPad, iMac, Macbook, iWatch).