Disable key for some time after releasing it Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
PoolersJr
Posts: 2
Joined: 07 Feb 2023, 10:10

Disable key for some time after releasing it

Post by PoolersJr » 07 Feb 2023, 10:16

Hello,

I am having trouble making a script that works as following:
When w is released, I want the script to disable pressing w down for half a second.

ananthuthilakan
Posts: 188
Joined: 08 Jul 2019, 05:37
Contact:

Re: Disable key for some time after releasing it

Post by ananthuthilakan » 07 Feb 2023, 11:44

Code: Select all

#Singleinstance force
w::
n++
tooltip, % n
return

w Up::
Hotkey, w , , off
Settimer, lbl_w_on, 500
return

lbl_w_on:
Hotkey, w , , On
return
welcome to Autohotkey forum!
try this

PoolersJr
Posts: 2
Joined: 07 Feb 2023, 10:10

Re: Disable key for some time after releasing it

Post by PoolersJr » 07 Feb 2023, 12:16

Hello, thank you for your reply!

When pressing "w", a label appears next to the cursor. The label seems to behave correctly, incrementing as w is pressed or held down, but if pressed too quickly in succession, not incrementing. The problem though, is that w is actually never pressed. How to fix this problem?

User avatar
mikeyww
Posts: 26938
Joined: 09 Sep 2014, 18:38

Re: Disable key for some time after releasing it  Topic is solved

Post by mikeyww » 07 Feb 2023, 15:27

For v2:

Code: Select all

#Requires AutoHotkey v2.0
disabled := False

~w Up:: {
 Global disabled := True
 SetTimer enable, -500
}

#HotIf disabled
w::Return
#HotIf

enable() {
 Global disabled := False
 SoundBeep 1500
}

Post Reply

Return to “Ask for Help (v1)”