Advertisement
Retsam19

How to detect how many times a hotkey can be triggered within 2 seconds?

Jun 12th, 2025
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Requires AutoHotkey v2.0
  2.  
  3.  
  4. MsgBox A_MaxHotkeysPerInterval "  " A_HotkeyInterval  ; 70 2000
  5. ; A_MaxHotkeysPerInterval :=256
  6. ; MsgBox A_MaxHotkeysPerInterval "  " A_HotkeyInterval  ;  
  7.  
  8.  
  9. #1:: {
  10.  
  11.     static start := A_TickCount
  12.     static times := 0
  13.     /**
  14.      * 如果从上一次按键到现在的事件超过了1000 则就认为是重新开始计算.
  15.      */
  16.     if (A_TimeSincePriorHotkey && (A_TimeSincePriorHotkey > 1000)) {
  17.         start := A_TickCount
  18.         times := 0
  19.     }
  20.  
  21.     if (A_TickCount - start > 2000) {
  22.  
  23.         MsgBox(times "  T:" (A_TickCount - start))
  24.     }
  25.     times++
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement