How i can stop hotkey spam ?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
djuga
Posts: 88
Joined: 28 Jul 2019, 08:16

How i can stop hotkey spam ?

Post by djuga » 03 Oct 2022, 01:59

If you hold T key, counter will increase number, but why, is there any way to prevent it without KeyWait , while , loop etc
How to change this behavior ?

Code: Select all

Hotkey, t , Test , On
return

Test:
Counter += 1
Tooltip, % Counter , 0 , 0 
;KeyWait, t ; This will work, but i want without this method
return
My questions are baffling! :crazy:

GEV
Posts: 999
Joined: 25 Feb 2014, 00:50

Re: How i can stop hotkey spam ?

Post by GEV » 03 Oct 2022, 04:07

without while loop:

Code: Select all

Hotkey, $t,    Test,   On
Hotkey, $t up, NoTest, On
return

Test:
	Counter += 1
	Tooltip, % Counter, 0, 0
	; Sleep, 300 ; if you want a delay
return

NoTest:
	Counter = 0
	Tooltip
return

Rohwedder
Posts: 7509
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How i can stop hotkey spam ?

Post by Rohwedder » 03 Oct 2022, 08:09

Hallo,
try:

Code: Select all

Goto, t UP
t UP::Hotkey, t , Test , On

Test:
Hotkey, t , Return
Counter += 1
Tooltip, % Counter , 0 , 0
Return:
return

djuga
Posts: 88
Joined: 28 Jul 2019, 08:16

Re: How i can stop hotkey spam ?

Post by djuga » 03 Oct 2022, 17:56

GEV wrote:
03 Oct 2022, 04:07
without while loop:

Code: Select all

Hotkey, $t,    Test,   On
Hotkey, $t up, NoTest, On
return

Test:
	Counter += 1
	Tooltip, % Counter, 0, 0
	; Sleep, 300 ; if you want a delay
return

NoTest:
	Counter = 0
	Tooltip
return
Counter still increases when you hold key, this is not what im asked
My questions are baffling! :crazy:

djuga
Posts: 88
Joined: 28 Jul 2019, 08:16

Re: How i can stop hotkey spam ?

Post by djuga » 03 Oct 2022, 17:58

Rohwedder wrote:
03 Oct 2022, 08:09
Hallo,
try:

Code: Select all

Goto, t UP
t UP::Hotkey, t , Test , On

Test:
Hotkey, t , Return
Counter += 1
Tooltip, % Counter , 0 , 0
Return:
return
Yes, it will work, but the request is different, need to change the behavior, for example, how directives do it, in your method you need to resort to constant binds, this is bad way :problem:
My questions are baffling! :crazy:

Rohwedder
Posts: 7509
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How i can stop hotkey spam ?

Post by Rohwedder » 04 Oct 2022, 00:38

What you call hotkey spam is not caused by Autohotkey, but by your Windows driver.
As long as the T key is held down, the driver sends {t Down} messages which trigger your T hotkey over and over again.

Code: Select all

#InstallKeybdHook
Hotkey, t , Test , On
t Up::KeyHistory
Test:
Counter += 1
Tooltip, % Counter , 0 , 0
return
KeyHistoryVK SC Type Up/Dn Elapsed Key Window
-------------------------------------------------------------------------------------------------------------
54 014 h d 3.84 t Unbenannt - Editor
54 014 h d 0.52 t
54 014 h d 0.05 t
54 014 h d 0.03 t
54 014 h d 0.03 t
54 014 h d 0.03 t
54 014 h d 0.03 t
54 014 h d 0.03 t
54 014 h d 0.05 t

This does not happen with mouse buttons.

Code: Select all

Hotkey, RButton , Test , On
return

Test:
Counter += 1
Tooltip, % Counter , 0 , 0
return
Either you change the driver or intercept the driver spam via script.

Post Reply

Return to “Ask for Help (v1)”