为什么 autohotkey deos 不发送 Ctrl-Space 其中 Space 是输入
Why autohotkey deos not send Ctrl-Space where Space is an input
考虑以下作业:
当我键入 -
后跟 key
时,结果是 Ctrl-key
。这适用于普通钥匙。
但是当键是空格时,它不起作用。
知道为什么会这样吗?以及如何修复代码?
-::
Input, key, L1,{LCtrl}
send, ^{%key%}
return
编辑。
尝试将上面的脚本 运行 编写为一个以 Ctrl-Space 作为快捷方式的程序,看看它是否有效。事实上,如果您按 -
,然后按 Space
,脚本应该调用 Ctrl-Space
,但事实并非如此。例如:
- 在 Microsoft Excel 或 Libreoffice Calc 中,Ctrl-Space 可以 select 当前列。
- 在 Emacs 中,Ctrl-Space 保留用于设置标记。
改用SendInput
。
在 Excel 中测试以模拟 ^a、^x、^v、^space
-::
Input, key, L1,{LCtrl}
SendInput, ^%key%
Return
如果您想处理“特殊”键,请使用此语法将这些键添加到结束键列表中
Input [, OutputVar, Options, EndKeys, MatchList]
然后检查按下的是哪个结束键
在 Firefox 中测试以模仿 ^PgDn、^PgUp
Input, key, L1,{LCtrl}{PgUp}{PgDn}
If (ErrorLevel = "EndKey:PgUp") {
SendInput ^{PgUp}
}
Else If (ErrorLevel = "EndKey:PgDn") {
SendInput ^{PgDn}
}
Else If (ErrorLevel = "EndKey:LCtrl") {
Return ;assumed you just want to abort input with the control key
}
Else {
SendInput, ^%key%
}
Return
考虑以下作业:
当我键入 -
后跟 key
时,结果是 Ctrl-key
。这适用于普通钥匙。
但是当键是空格时,它不起作用。
知道为什么会这样吗?以及如何修复代码?
-::
Input, key, L1,{LCtrl}
send, ^{%key%}
return
编辑。
尝试将上面的脚本 运行 编写为一个以 Ctrl-Space 作为快捷方式的程序,看看它是否有效。事实上,如果您按 -
,然后按 Space
,脚本应该调用 Ctrl-Space
,但事实并非如此。例如:
- 在 Microsoft Excel 或 Libreoffice Calc 中,Ctrl-Space 可以 select 当前列。
- 在 Emacs 中,Ctrl-Space 保留用于设置标记。
改用SendInput
。
在 Excel 中测试以模拟 ^a、^x、^v、^space
-::
Input, key, L1,{LCtrl}
SendInput, ^%key%
Return
如果您想处理“特殊”键,请使用此语法将这些键添加到结束键列表中
Input [, OutputVar, Options, EndKeys, MatchList]
然后检查按下的是哪个结束键
在 Firefox 中测试以模仿 ^PgDn、^PgUp
Input, key, L1,{LCtrl}{PgUp}{PgDn}
If (ErrorLevel = "EndKey:PgUp") {
SendInput ^{PgUp}
}
Else If (ErrorLevel = "EndKey:PgDn") {
SendInput ^{PgDn}
}
Else If (ErrorLevel = "EndKey:LCtrl") {
Return ;assumed you just want to abort input with the control key
}
Else {
SendInput, ^%key%
}
Return