How to ignore/disable keys for X amount of time - AHK

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
imstupidpleshelp
Posts: 2
Joined: 28 Mar 2024, 11:02

How to ignore/disable keys for X amount of time - AHK

28 Mar 2024, 11:05

Code: Select all

$e:: ;$ To avoid autoignition
SetKeyDelay, 200, 50 ;SetKeyDelay , Delay, PressDuration
Send, {e}
Send, {w}
Send, {t}
Return
This is the macro I'm using now but I want to disable/ignore w and t for X amount of time after the 1st use

Then they continue their normal action after X allotted time has passed BUT only execute that action once "e" is once again pressed

How is that accomplished?


[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

[Mod action: Topic moved from "Ask for Help (v2)" since this is v1 code.]
imstupidpleshelp
Posts: 2
Joined: 28 Mar 2024, 11:02

Re: How to ignore/disable keys for X amount of time - AHK

28 Mar 2024, 13:21

Code: Select all

bool := true
time := 6000 ;milliseconds 

$e::
	if (bool) {
		SetTimer enabler, % -time
	}
	SetKeyDelay 200, 50 
	Send % "e" (bool ? "wt" : "")
	bool := false
	Return
	
enabler() {
	global bool := true
}
[Mod edit: Added [code][/code] tags.]

The above code seems to solve the problem. However, the script stops working pretty quickly after a minute or two of use. Could it be a memory leak problem?
User avatar
gregster
Posts: 9224
Joined: 30 Sep 2013, 06:48

Re: How to ignore/disable keys for X amount of time - AHK

28 Mar 2024, 13:25

@imstupidpleshelp, we again added code tags to your post. Please use them yourself when posting code. Thank you!


ctags.png
ctags.png (14.18 KiB) Viewed 113 times

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 152 guests