【发布时间】:2021-12-15 04:43:58
【问题描述】:
例如,我想在 ahk 中设置一个计时器,如果一个键的持有时间少于 1000 毫秒,它会更改为例如。 Esc,如果保持超过一秒,是否会执行其他脚本?
提前谢谢你。
【问题讨论】:
-
将this example
T0.5替换为T1,并将Send ^w替换为例如Run D:\Folder\My Script.ahk(脚本的路径你想被执行)。
标签: autohotkey
例如,我想在 ahk 中设置一个计时器,如果一个键的持有时间少于 1000 毫秒,它会更改为例如。 Esc,如果保持超过一秒,是否会执行其他脚本?
提前谢谢你。
【问题讨论】:
T0.5 替换为 T1,并将 Send ^w 替换为例如 Run D:\Folder\My Script.ahk(脚本的路径你想被执行)。
标签: autohotkey
我相信这个代码论坛可以帮到你。
来源:https://www.autohotkey.com/boards/viewtopic.php?t=82436
; triple Tap or Hold key snippet
;??????????????????????????????????????\ .----------------------------------------+
return ; ¦
Timer: ; - - triple Tap + Hold - BLOCK 1 - - ¦
{ ; This is the block that starts ¦
If !%A_ThisHotkey%key ; the count forall Hotkeys. ¦
SetTimer, %A_ThisHotkey%key, -400 ; Make sure it is placed above ¦
%A_ThisHotkey%key++ ; Block 2 & that the prefix is changed ¦
Return ; to match the key's Name, as only 1 ¦
} ; may Exist. instance of this lable ¦
;______________________________________/ `----------------------------------------+
Q:: goto timer
;???????????????????????????????????????????\
qkey: ; +------------------+
If GetKeyState("q","P") and %A_ThisLabel%=1 ;>----------¦ Hold Action ¦
msgbox you held down the key Q ; +------------------+
; - - - - - - - - - - - - - - +
Else If %A_ThisLabel% = 3 ; +------------------+
msgbox you pressed the key Q 3 times ;>----------¦ 3X Press Action ¦
; - - - - - - - - - - - - - - + +------------------+
Else If %A_ThisLabel% = 2 ; +------------------+
msgbox you pressed the key Q 2 times ;>----------¦ 2X Press Action ¦
; - - - - - - - - - - - - - - + +------------------+
Else If %A_ThisLabel% = 1 ; +------------------+
msgbox you pressed the key Q 1 time ;>----------¦ 1X Press Action ¦
; - - - - - - - - - - - - - - + +------------------+
%A_ThisLabel%=0 ;
return ;
;___________________________________________/
key:
return
【讨论】: