Why would this code send random Left Clicks?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Noo0B
Posts: 151
Joined: 26 Jan 2018, 19:54

Why would this code send random Left Clicks?

25 Feb 2018, 02:58

Hello,
Here is the code:

Code: Select all


	%HKeyHkKeyT1%toggle := !%HKeyHkKeyT1%toggle
		If %HKeyHkKeyT1%toggle {
				While %HKeyHkKeyT1%toggle {
					ImageSearch, , , 0, 0, 1000, 80, % "*10 " HKeyHkS1T1 "Timer.png"
						If ErrorLevel = 1
							ImageSearch, , , 0, 0, 1000, 80, % "*10 " HKeyHkS1T1 "Timer3.png"
								if ErrorLevel = 0
									SetEnv, %HKeyHkS1T1%Timer, True
								if ErrorLevel = 1
									SetEnv, %HKeyHkS1T1%Timer, False
						If %HKeyHkS1T1%timer = False
							{
							ImageSearch, , , 1575, 1020, 1630, 1075, % "*10 " HKeyHkS1T1 "-" HKeyHkKeyT1 ".png"
								If ErrorLevel = 0
;The random amounts of Left clicks happen around here when holding down the left button and reset the loop after each click but won't show on the log. This didn't happen when this script wasn´t using variables. Sometimes it works as its supposed, sometimes sends a few clicks before sending the right input. Most times sends 1 left click then a bit later (Sleep, 1000) the correct send input.
									Send, {%HKeyHkKeyT1%}
								If (ErrorLevel = 1) {
									MouseGetPos, Xpos, Ypos
									BlockInput, MouseMove
									GetKeyState, LButtonstate, LButton
										If LButtonstate = D
											Mouseclick, , , , , , U
									MouseClick, , KeyXt1_Hk, KeyYt1_Hk
									MouseClick, , %HKeyHkS1T1%X, %HKeyHk1T1%Y
									Send, {%HKeyHkKeyT1%}
										If LButtonstate = D
											Mouseclick, , , , , , D
									MouseMove, Xpos, Ypos
									BlockInput, MouseMoveOff
								}
							}
					Sleep, 1000
				}
			Return
		}
Thanks for the attention and Regards!
Noo0B
Posts: 151
Joined: 26 Jan 2018, 19:54

Re: Why would this code send random Left Clicks?

25 Feb 2018, 03:44

It only works if I add

Code: Select all


											If (ErrorLevel = 0) {
												GetKeyState, LButtonstate, LButton
													if LButtonstate = D
														Mouseclick, , , , , , U
												Send, {%HKeyHkKeyT1%}
													If LButtonstate = D
														Mouseclick, , , , , , D
											}
But I don't want to bloat the script.
Any Ideas why this is happening?
Regards!
Noo0B
Posts: 151
Joined: 26 Jan 2018, 19:54

Re: Why would this code send random Left Clicks?

25 Feb 2018, 13:47

Apparently Its reevaluating this out of place:

Code: Select all


													If LButtonstate = D
														Mouseclick, , , , , , D
Noo0B
Posts: 151
Joined: 26 Jan 2018, 19:54

Re: Why would this code send random Left Clicks?

20 Jul 2018, 02:56

I could not find where the clicks were coming from, they were not logged. At ErrorLevel = o it was only supposed to send a keypress, but it sends up to a few random left clicks.
I patched it like above and called quits.
Noo0B
Posts: 151
Joined: 26 Jan 2018, 19:54

Re: Why would this code send random Left Clicks?

20 Jul 2018, 02:56

I could not find where the clicks were coming from, they were not logged. At ErrorLevel = 0 it was only supposed to send a keypress, but it sends up to a few random left clicks.
I patched it like above and called quits.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Frogrammer, gongnl and 269 guests