AppleScript的:脚本切换Caps Lock键来控制 [英] AppleScript: Script to switch Caps Lock Key to Control
问题描述
我是想,因为我使用的Vim,大部分我需要的大写锁定时间要分配给Ctrl键,找到一个解决这一点。有次,虽然我想大写锁定正常工作。我认为苹果的脚本是伟大的,因为它可以被分配到一个启动栏的动作。
我将与我结束了与解决方案(通过GUI脚本)回答,但如果有人知道的方式有兴趣干扰性较低的解决方案......
您可以使用 PCKeyboardHack 来改变大写锁定为F19。那么这个保存为 private.xml :
<?XML版本=1.0&GT?;
<根和GT;
<项目>
<名称>&caps1 LT; /名称>
<标识符GT; caps1< /标识符>
<&AUTOGEN GT; __ KeyToKey__重点code :: F19,重点code :: CAPSLOCK< / AUTOGEN>
< /项目>
<项目>
<名称>&caps2 LT; /名称>
<标识符GT; caps2< /标识符>
<&AUTOGEN GT; __ KeyToKey__重点code :: F19,重点code :: CONTROL_L< / AUTOGEN>
< /项目>
< /根>
和使用这个脚本来切换设置:
<$p$p><$c$c>k=/Applications/KeyRemap4MacBook.app/Contents/Applications/KeyRemap4MacBook_cli.app/Contents/MacOS/KeyRemap4MacBook_cli如果换成$ K | grep的-q ^ caps1 =;然后
$ķ禁用caps1
$ķ使caps2
其他
$ķ使caps1
$ķ禁用caps2
科幻
这将是容易只是指定另一个组合键大写锁定,但:
&LT; AUTOGEN&GT; __ KeyOverlaidModifier__重点code :: CONTROL_L,ModifierFlag :: FN,重点code :: CONTROL_L,ModifierFlag :: FN,重点code :: CAPSLOCK&LT ; / AUTOGEN&GT;
这将在关键触发了,所以你必须FN像FN +控制键组合之前preSS控制+下来:
&LT; AUTOGEN&GT; __ KeyToKey__重点code :: CONTROL_L,ModifierFlag :: FN,重点code :: CAPSLOCK&LT; / AUTOGEN&GT;
I was trying to find a solution to this because I am using Vim and most of the time I need Caps lock to be assigned to Ctrl. There are times though that I want the Caps Lock working normally. I thought an Apple Script is great as it can be assigned to a LaunchBar action.
I will answer with the solution I ended up with (through GUI scripting) but would be interested in a less intrusive solution if someone knows a way...
You can use PCKeyboardHack to change caps lock to F19. Then save this as private.xml:
<?xml version="1.0"?>
<root>
<item>
<name>caps1</name>
<identifier>caps1</identifier>
<autogen>__KeyToKey__ KeyCode::F19, KeyCode::CAPSLOCK</autogen>
</item>
<item>
<name>caps2</name>
<identifier>caps2</identifier>
<autogen>__KeyToKey__ KeyCode::F19, KeyCode::CONTROL_L</autogen>
</item>
</root>
And use this script to toggle the settings:
k=/Applications/KeyRemap4MacBook.app/Contents/Applications/KeyRemap4MacBook_cli.app/Contents/MacOS/KeyRemap4MacBook_cli
if $k changed | grep -q ^caps1=; then
$k disable caps1
$k enable caps2
else
$k enable caps1
$k disable caps2
fi
It would be easier to just assign another key combination to caps lock though:
<autogen>__KeyOverlaidModifier__ KeyCode::CONTROL_L, ModifierFlag::FN, KeyCode::CONTROL_L, ModifierFlag::FN, KeyCode::CAPSLOCK</autogen>
This would be triggered on key down, so you'd have to press control before fn for key combinations like fn+control+down:
<autogen>__KeyToKey__ KeyCode::CONTROL_L, ModifierFlag::FN, KeyCode::CAPSLOCK</autogen>
这篇关于AppleScript的:脚本切换Caps Lock键来控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!