Autohotkey 区分物理按键笔划和重复按键
在自动热键中:有没有办法区分物理键笔划和重复键 我正在寻找网络中的对等物 我希望能找到这样更好的东西:Autohotkey 区分物理按键笔划和重复按键,autohotkey,Autohotkey,在自动热键中:有没有办法区分物理键笔划和重复键 我正在寻找网络中的对等物 我希望能找到这样更好的东西: *key1:: If (hotkey1_active) return hotkey1_active := 1 Myfunction1() return *key1 up:: hotkey1_active := 0 return 找到了上面的示例代码。AFAIK没有用于键控检查的内置语法。但您可以在循环中使用检查状态: key := "a" state0 := getkeystate(
*key1::
If (hotkey1_active)
return
hotkey1_active := 1
Myfunction1()
return
*key1 up::
hotkey1_active := 0
return
找到了上面的示例代码。AFAIK没有用于键控检查的内置语法。但您可以在循环中使用检查状态:
key := "a"
state0 := getkeystate(key, "P") ; init key state
c := 0
loop
{
sleep 30 ; sleep to reduce CPU usage
state1 := getkeystate(key, "P") ; getkeystate
state_on := (state1 > state0) ; check if key state is changed to 'on'
; state_off := (state1 < state0) ; check if key state is changed to 'off'
state0 := state1 ; save previous state
if (state_on) {
c += 1
tooltip %key% pressed %c% times
; Myfunction1()
}
}
键:=“a”
state0:=getkeystate(键,“P”);初始密钥状态
c:=0
环
{
睡眠30;睡眠以减少CPU使用
状态1:=getkeystate(键,“P”);getkeystate
状态_on:=(状态1>状态0);检查键状态是否更改为“开”
;state_off:=(state1
很有可能这就是物理状态的变化。没有办法知道,唯一知道的是重复动作是由向下键组成的,没有向上键 也许有办法不必为每个热键创建变量 试试这个,我认为它在正常情况下已经足够好了:
*a::
if (A_PriorHotkey = A_ThisHotKey)
return
Myfunction1()
return
*a Up:: return ; Does nothing but change A_PriorHotkey.
getkeystate始终返回true。情况是,我按下一个键并按住它5秒钟。在这5秒钟内,我收到了数百个我喜欢检测(并忽略)的相同热键。@sam如果你也需要对重复事件进行处理,那么这当然不是你想要的。您的初始代码的一些变体应该可以完成这项工作。仍然不是我所希望的,但至少您的解决方案不需要额外的变量