PixelGetColor / PixelSearch loop gets stuck when result is the same

Get help with using AutoHotkey and its commands and hotkeys
Joop85
Posts: 2
Joined: 14 Jan 2019, 05:32

PixelGetColor / PixelSearch loop gets stuck when result is the same

14 Jan 2019, 05:49

Hi all,

I'm using PixelGetColor to find a color and with that result I use a loop with if else statement to perform a PixelSearch and use the coordinates to send a mouse click.
It all works fine, until the PixelGetColor result is the same as before. The PixelSearch works, but the mouse click is not being sent.

Example:
Color Result
Purple Ok
Red Ok
Purple Ok
Blue Ok
Blue Stops

Anybody knows what could be the issue?

My script:

Code: Select all

#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
#MaxMem 4095
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

!x::

Loop	
{
	Sleep 1000
	PixelGetColor, Color, 1000, 530
	
	if (Color = 0xFFA0BC) ; Purple color
	{ 
		PixelSearch, Px, Py, 750, 900, 1200, 1000, 0xD78895, 3, Fast
		Px+=50
		Py+=50
		Send {Click, down, %Px%, %Py%}
	}	
	else if (Color = 0x5FFFCA) ; Green color
	{ 
		PixelSearch, Px, Py, 750, 900, 1200, 1000, 0x3EE0BF, 3, Fast
		Px+=50
		Py+=50
		Send {Click, down, %Px%, %Py%}
	}
	else if (Color = 0xFFE401) ; Blue color
	{ 
		PixelSearch, Px, Py, 750, 900, 1200, 1000, 0xE0C93E, 3, Fast
		Px+=50
		Py+=50
		Send {Click, down, %Px%, %Py%}
	}
	else if (Color = 0x4969FF) ; Red color
	{ 
		PixelSearch, Px, Py, 750, 900, 1200, 1000, 0x2D40E1, 3, Fast
		Px+=50
		Py+=50
		Send {Click, down, %Px%, %Py%}
	}
}
Return

Esc::ExitApp
WalkerOfTheDay
Posts: 338
Joined: 24 Mar 2016, 03:01

Re: PixelGetColor / PixelSearch loop gets stuck when result is the same

14 Jan 2019, 06:00

Perhaps you need to clear the variable [color], not sure tbo..
Joop85
Posts: 2
Joined: 14 Jan 2019, 05:32

Re: PixelGetColor / PixelSearch loop gets stuck when result is the same

14 Jan 2019, 06:30

I tried that. Doesn't make a difference.

I did put a msgbox in between to check if it identifies the color and it does, so the PixelGetColor looks like it's working. I was afraid that it wouldn't return a value because it's the same as before.

Any other suggestions?

Thanks for responding :)

Return to “Ask For Help”

Who is online

Users browsing this forum: _Ne0n, blue83, Google [Bot], rommmcek, SeriousScrooge and 50 guests