Stuck in a loop

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Weshuggah
Posts: 15
Joined: 31 May 2020, 11:13

Stuck in a loop

14 May 2021, 14:39

Hello,

So I have this simple script that spams Middle mouse button with random speed while holding it and I noticed a weird behavior: sometimes when I'm holding middle button and also pressing and releasing Right click, then releasing Middle button, it gets stuck spamming until I press and release middle button again.
This is a while loop but I also tried with regular loop and noticed the same behavior, I tried to mess with SetBatchLines and sendmode values but sadly didnt fix it. This issue only happens when interacting with Right click. I'm clueless...

Code: Select all

MButton::
SetTimer, pingspam, -200
return

pingspam:
Random, SleepAmount, 10, 150
	While GetKeyState("MButton","P") {
	Send, {MButton}
	Sleep, %SleepAmount%
	}
return
User avatar
Smile_
Posts: 858
Joined: 03 May 2020, 00:51

Re: Stuck in a loop

14 May 2021, 15:21

Add this to your script, it might fix it

Code: Select all

MButton Up::
    SetTimer, pingspam, Off
Return
But I don't know the use of a timer in this, doesn't seem to be needed.
Weshuggah
Posts: 15
Joined: 31 May 2020, 11:13

Re: Stuck in a loop

14 May 2021, 15:47

I use settimer to delay the beginning of spamming, so I can still use middle button normally as long as I dont hold it for more than 200ms.
Sadly it didn't fix it, also tried to disable timer just after the while loop, but same thing..

edit: so I removed the timer and kept only the while loop, it still does it, when Im using right click while holding mbutton, sometimes it gets stuck in loop. It doesnt do it with any other key or mouse button.. really weird.
Green
Posts: 17
Joined: 22 Jan 2019, 23:06

Re: Stuck in a loop

22 Aug 2021, 19:49

Has anyone figured out any solution to this ?

I have tried many things and it didn't work, the while loop sometimes gets stuck and it's impossible to break out till the key is pressed again physically, tried to release key didn't work from the script.

Also tried without Settimer simple while loop same result

Code: Select all

Loop 
{
 ;Something
} Until (!GetKeyState("MButton", "P"))
I don't understand the KeyboardHook how could it work here.

Reload works fine.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, sharonhuston and 225 guests