【问题标题】:How to make different hotkeys for a key being tapped vs a key being held for 1000ms如何为被点击的键和被按住 1000 毫秒的键创建不同的热键
【发布时间】:2021-12-15 04:43:58
【问题描述】:

例如,我想在 ahk 中设置一个计时器,如果一个键的持有时间少于 1000 毫秒,它会更改为例如。 Esc,如果保持超过一秒,是否会执行其他脚本?

提前谢谢你。

【问题讨论】:

  • this example T0.5 替换为 T1,并将 Send ^w 替换为例如 Run D:\Folder\My Script.ahk(脚本的路径你想被执行)。

标签: autohotkey


【解决方案1】:

我相信这个代码论坛可以帮到你。

来源: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

【讨论】:

  • 那些cmets ....?...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-10-10
  • 1970-01-01
  • 1970-01-01
  • 2012-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多