Ignore hotkey for "x" seconds? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Crushthebug
Posts: 18
Joined: 07 Mar 2017, 04:30

Ignore hotkey for "x" seconds?

07 Mar 2017, 04:46

So I'm setting up a script that is triggered with ~Shift & ~RButton. The macro works and everything, but I'm trying to get it so that the script will ignore my trigger hotkey (~Shift & ~Rbutton) for 5 seconds. Basically, I'm spamming Shift and Right Click together very often and I want to effectively disable the script (meaning I can press it without action) for 5 seconds. After 5 seconds passes, the script is free to be triggered again.

I'd like it to work like this:

spamming Shift and Right Click > Macro runs > 5 seconds pass (still spamming Shit and Right Click) > Macro can run again

Here is the current script

__________________________________

Code: Select all

~Shift & ~RButton::
	{
			Send, {2 down} {2 up}
			Sleep 48 ; milliseconds
		}
		{
			Send, {3 down} {3 up}
			Sleep 42 ; milliseconds
		}
		{
			Send, {4 down} {4 up}
			Sleep 38 ; milliseconds
		}
		{
			Send, {5 down} {5 up}
			Sleep 26 ; milliseconds
	}
Return
If anyone knows how to do this, I'd be super thankful!
Rohwedder
Posts: 7648
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Ignore hotkey for "x" seconds?  Topic is solved

07 Mar 2017, 05:48

Hello,
try:

Code: Select all

~Shift & ~RButton::
	If (A_TickCount < NextTime)
		Return
	NextTime := A_TickCount + 5000
	Send, {2 down} {2 up}
	Sleep 48 ; milliseconds
	Send, {3 down} {3 up}
	Sleep 42 ; milliseconds
	Send, {4 down} {4 up}
	Sleep 38 ; milliseconds
	Send, {5 down} {5 up}
	Sleep 26 ; milliseconds
Return
Crushthebug
Posts: 18
Joined: 07 Mar 2017, 04:30

Re: Ignore hotkey for "x" seconds?

07 Mar 2017, 12:22

Rohwedder wrote:Hello,
try:

Code: Select all

~Shift & ~RButton::
	If (A_TickCount < NextTime)
		Return
	NextTime := A_TickCount + 5000
	Send, {2 down} {2 up}
	Sleep 48 ; milliseconds
	Send, {3 down} {3 up}
	Sleep 42 ; milliseconds
	Send, {4 down} {4 up}
	Sleep 38 ; milliseconds
	Send, {5 down} {5 up}
	Sleep 26 ; milliseconds
Return
That functions EXACTLY as I was trying for. Thanks a lot, I didn't even know about TickCount.

Seriously Kudos.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: metallizer and 124 guests