如何在 Autohotkey 中设置组合阈值
How to set combination threshold in Autohotkey
关于如何在 AutoHotkey 中定义自定义组合的说明:
You can define a custom combination of two keys (except joystick
buttons) by using " & " between them. In the below example, you would
hold down Numpad0 then press the second key to trigger the hotkey:
Numpad0 & Numpad1::MsgBox "You pressed Numpad1 while holding down Numpad0."
Numpad0 & Numpad2::Run "Notepad"
但我找不到如何设置阈值。例如,我希望 Numpad0 & Numpad1
仅在用户按下 Numpad0
后不到 300 毫秒按下 Numpad1
时发生。
例如,您可以这样做:
Numpad0::
if (!PressedAt)
PressedAt := A_TickCount
return
Numpad0 Up::PressedAt := 0
#If, A_TickCount - PressedAt < 300
Numpad1::MsgBox
#If
所以用A_TickCount
(docs)比较时间
if 语句的存在是因为 Windows' 键重复功能。没有它,PressedAt
时间将在按住 Numpad0 时不断设置。
此外,0
是 false
,因此我们也可以方便地在 if 语句中使用 PressedAt
变量。
如果没有 Numpad1 的上下文敏感热键也可以完成,它只是让键保留其原始功能。
如果 #If
导致你 trouble,你可以切换到热键标签内的正常 if 语句检查。
如果需要,请务必将 ~
前缀 (docs) 添加到 Numpad0 热键。
关于如何在 AutoHotkey 中定义自定义组合的说明:
You can define a custom combination of two keys (except joystick buttons) by using " & " between them. In the below example, you would hold down Numpad0 then press the second key to trigger the hotkey:
Numpad0 & Numpad1::MsgBox "You pressed Numpad1 while holding down Numpad0." Numpad0 & Numpad2::Run "Notepad"
但我找不到如何设置阈值。例如,我希望 Numpad0 & Numpad1
仅在用户按下 Numpad0
后不到 300 毫秒按下 Numpad1
时发生。
例如,您可以这样做:
Numpad0::
if (!PressedAt)
PressedAt := A_TickCount
return
Numpad0 Up::PressedAt := 0
#If, A_TickCount - PressedAt < 300
Numpad1::MsgBox
#If
所以用A_TickCount
(docs)比较时间
if 语句的存在是因为 Windows' 键重复功能。没有它,PressedAt
时间将在按住 Numpad0 时不断设置。
此外,0
是 false
,因此我们也可以方便地在 if 语句中使用 PressedAt
变量。
如果没有 Numpad1 的上下文敏感热键也可以完成,它只是让键保留其原始功能。
如果 #If
导致你 trouble,你可以切换到热键标签内的正常 if 语句检查。
如果需要,请务必将 ~
前缀 (docs) 添加到 Numpad0 热键。