为什么 autohotkey 不能将 {Backspace} 保存为输入?
Why autohotkey cannot save {Backspace} as an input?
考虑以下代码。在键入 x 后跟 {Backspace} 我希望收到退格键但 autohotkey 没有显示反应。对于其他键,不会出现此问题。有没有办法修复此代码?
~x::
Input Key, L1
if Key=s
{
do something
exit
}
else {
send %Key%
}
return
一个明确的例子:
~x::
Input Key, L1
if Key=s
{
send blablabla
exit
}
else {
send %Key%
}
return
您可以将 BackSpace
和所有其他键放在 Input
命令的第三个 EndKeys
参数中,然后在按下时发送 EndKey
。
~x::
Input Key, L1, {BackSpace}{Enter}{LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
; If end key was pressed, extract it and replace `Key` with the EndKey
FoundPos := RegExMatch(ErrorLevel, "EndKey:(.*)", SubPat)
if (FoundPos > 0)
Key = {%SubPat1%}
if (Key="s")
send blablabla
else
send %Key%
return
您可以在 documentation.
中找到更多相关信息
另一种解决方案是使用 A_PriorKey
检查 x
是否在 s
之前被按下。
; $ is required to prevent the hoteky from firing itself
$s::
if (A_PriorKey = "x")
Send blablabla
else
Send s
return
考虑以下代码。在键入 x 后跟 {Backspace} 我希望收到退格键但 autohotkey 没有显示反应。对于其他键,不会出现此问题。有没有办法修复此代码?
~x::
Input Key, L1
if Key=s
{
do something
exit
}
else {
send %Key%
}
return
一个明确的例子:
~x::
Input Key, L1
if Key=s
{
send blablabla
exit
}
else {
send %Key%
}
return
您可以将 BackSpace
和所有其他键放在 Input
命令的第三个 EndKeys
参数中,然后在按下时发送 EndKey
。
~x::
Input Key, L1, {BackSpace}{Enter}{LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
; If end key was pressed, extract it and replace `Key` with the EndKey
FoundPos := RegExMatch(ErrorLevel, "EndKey:(.*)", SubPat)
if (FoundPos > 0)
Key = {%SubPat1%}
if (Key="s")
send blablabla
else
send %Key%
return
您可以在 documentation.
中找到更多相关信息另一种解决方案是使用 A_PriorKey
检查 x
是否在 s
之前被按下。
; $ is required to prevent the hoteky from firing itself
$s::
if (A_PriorKey = "x")
Send blablabla
else
Send s
return