我正在尝试复制触摸光标键,但我无法让它与多个修饰符一起工作。
这是我目前所拥有的(来自https://autohotkey.com/boards/viewtopic.php?t=6525):
space & g::Send, {esc}
space & l::send, {right}
space & k::send, {up}
space & j::send, {down}
space & h::send, {left}
space & p::send, {backspace}
space & m::send, {delete}
space & u::send, {home}
space & o::send, {end}
space::
Send, {space}
return
上述脚本可以很好地使用“h”、“j”、“k”和“l”移动光标,但它忽略了control
和shift
键。
例如,我希望使用 ++ 来突出space
显示左侧的字母shift
,h
类似于space
++ shift
。left arrow
我尝试过:+space & h::send, {left}
并收到以下错误:
编辑
该脚本将与control
和 一起使用shift
:
; Right, Shift+Right, Control+Right, Shift+Control+Right
space & l::
if((GetKeyState("Shift", "P") and (GetKeyState("Control", "P")))) {
send, +^{right}
} else if(GetKeyState("Shift", "P")) {
send, +{right}
} else if(GetKeyState("Control", "P")) {
send, ^{right}
} else {
send, {right}
}
Return
; Up, Shift+Up, Control+Up, Shift+Control+Up
space & k::
if((GetKeyState("Shift", "P") and (GetKeyState("Control", "P")))) {
send, +^{up}
} else if(GetKeyState("Shift", "P")) {
send, +{up}
} else if(GetKeyState("Control", "P")) {
send, ^{up}
} else {
send, {up}
}
Return
; Down, Shift+Down, Control+Down, Shift+Control+Down
space & j::
if((GetKeyState("Shift", "P") and (GetKeyState("Control", "P")))) {
send, +^{down}
} else if(GetKeyState("Shift", "P")) {
send, +{down}
} else if(GetKeyState("Control", "P")) {
send, ^{down}
} else {
send, {down}
}
Return
; Left, Shift+Left, Control+Left, Shift+Control+Left
space & h::
if((GetKeyState("Shift", "P") and (GetKeyState("Control", "P")))) {
send, +^{left}
} else if(GetKeyState("Shift", "P")) {
send, +{left}
} else if(GetKeyState("Control", "P")) {
send, ^{left}
} else {
send, {left}
}
Return
; Home, Shift+Home, Control+Home, Shift+Control+Home
space & u::
if((GetKeyState("Shift", "P") and (GetKeyState("Control", "P")))) {
send, +^{home}
} else if(GetKeyState("Shift", "P")) {
send, +{home}
} else if(GetKeyState("Control", "P")) {
send, ^{home}
} else {
send, {home}
}
Return
; End, Shift+End, Control+End, Shift+Control+End
space & o::
if((GetKeyState("Shift", "P") and (GetKeyState("Control", "P")))) {
send, +^{end}
} else if(GetKeyState("Shift", "P")) {
send, +{end}
} else if(GetKeyState("Control", "P")) {
send, ^{end}
} else {
send, {end}
}
Return
; Backspace, Shift+Backspace
space & p::
if(GetKeyState("Control", "P")) {
send, ^{backspace}
} else {
send, {backspace}
}
Return
; Simple modifiers
space & g::Send, {esc}
space & m::send, {delete}
; Allow space bar to go through if pressed without holding
space::
Send, {space}
return
答案1
您需要使用if 语句与获取按键状态函数来捕获额外的修饰符。具体来说就是找到修饰符P
的(物理状态)shift
。
例如,以下space & h
组合:
space & h::
if(GetKeyState("Shift", "P")) {
send, +{left}
} else {
send, {left}
}
Return
我猜你可能会更进一步,想要实现修饰符ctrl
。你需要扩展 if 语句,并注意 if 语句的执行方式。
space & h::
if((GetKeyState("Shift", "P") and (GetKeyState("Control", "P")))) {
send, +^{left}
} else if(GetKeyState("Shift", "P")) {
send, +{left}
} else if(GetKeyState("Control", "P")) {
send, ^{left}
} else {
send, {left}
}
Return
您需要首先检查Shift
和的键状态Control
,然后检查各个修饰符,否则它会过早退出并且只执行其中一个修饰符。