Sometimes stuck in loop

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Deecy
Posts: 16
Joined: 12 Mar 2017, 18:20

Sometimes stuck in loop

12 Mar 2017, 18:24

Hi,
Try to link Shift+RMB to my RMB and do it until I release my right click

Code: Select all

RButton::
	Loop
	{
		GetKeyState, var, RButton, P
		If var=U
			Break
		Send {Shift down}{RButton down}{RButton up}{Shift up}
		Sleep 77
	}
	Return
It's work but don't know why sometimes I'm stuck on the loop until I right click again.
Any idea ?

Thank's
User avatar
Almost_there
Posts: 404
Joined: 30 Sep 2014, 10:32

Re: Sometimes stuck in loop

12 Mar 2017, 18:43

What about inserting Send {RButton up} before the loop?

You could also force a limit loop, example by Loop, 50 will cause the loop to run no further than 50 iterations.
Deecy
Posts: 16
Joined: 12 Mar 2017, 18:20

Re: Sometimes stuck in loop

21 Mar 2017, 16:23

Hi

Inserting Send {Rbutton up} have no effect. Stuck sometimes.
I don't want to force a limit loop cause I use it to cast a skill
Noesis
Posts: 301
Joined: 26 Apr 2014, 07:57

Re: Sometimes stuck in loop

22 Mar 2017, 00:36

Can't say I know why it would get stuck (it shouldn't, unless this is a excerpt of a script with additional hotkeys), but try this it's possibly less likely to get stuck, but is also a cleaner way to code for achieving the same thing.

Code: Select all

RButton::
	While GetKeyState("RButton", "P")
	{
		Send {Shift down}{RButton down}{RButton up}{Shift up}
		Sleep 77
	}
	Return
Deecy
Posts: 16
Joined: 12 Mar 2017, 18:20

Re: Sometimes stuck in loop

22 Mar 2017, 02:45

That was my first version of the script with the same problem.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Sometimes stuck in loop

22 Mar 2017, 08:02

Code: Select all

~*RButton::
{
	While GetKeyState("RButton", "P") {
		Send {Shift Down}
		Send {RButton Down}
	}
		Send {RButton Up}
		Send {Shift Up}
return
}
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Sometimes stuck in loop

22 Mar 2017, 13:47

Maybe use a timer instead,

Code: Select all

RButton::SetTimer,rb,77
RButton up::SetTimer,rb,off
rb:
	Send {Shift down}{RButton down}{RButton up}{Shift up}
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 275 guests