Simple PixelSearch script not working correctly Topic is solved

Ask gaming related questions (AHK v1.1 and older)
FluffyMrKitty
Posts: 14
Joined: 24 May 2018, 19:43

Simple PixelSearch script not working correctly

24 May 2018, 19:50

Heyo. First things first, the script:

Code: Select all

SetBatchLines, -1

~*RButton::
Loop
{	
	if (GetKeyState("RButton", "P")=0)
	{
		Click, up
		break
	}
	PixelSearch, Px, Py, 1047, 585, 1047, 599, 0xacb1b5, 75
	if (ErrorLevel=1)
	{
		Click, down
	}
	PixelSearch, Px, Py, 1047, 585, 1047, 599, 0x4f5a57, 75
	if (ErrorLevel=1 and GetKeyState("LButton", "P")=1)
	{
		Click, down
	}
	if (ErrorLevel=1 and GetKeyState("LButton", "P")=0)
	{
		Click, up
	}
}
return

*F10::ExitApp
Now here's my issue. The first PixelSearch is constantly returning an ErrorLevel value of 0 for some unknown reason and thus constantly holding down left click. Sometimes it works, but most often it doesn't. There's no rhyme or reason to it that I can see and I've been bashing my head against this for two days now. Hopefully someone can help me out!
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Simple PixelSearch script not working correctly

24 May 2018, 20:41

It looks like you want to search a column of pixels 1 pixel wide by 14 pixels high.
1047, 585, 1047, 599
should be:
1047, 585, 1048, 599

Also take a look at CoordMode in the docs.

HTH
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Simple PixelSearch script not working correctly

25 May 2018, 02:12

Also are these colors BGR formatted?
FluffyMrKitty
Posts: 14
Joined: 24 May 2018, 19:43

Re: Simple PixelSearch script not working correctly  Topic is solved

25 May 2018, 14:21

They are BGR formatted and I've decided that I only needed one pixel for accurate results, not a 1-wide column. I also implemented CoordMode for other reasons, but I did get it working in the end. Turned out it was an issue with the exe I was trying to PixelSearch from. It was blocking AHK and any other screen-grabbing program for that matter from getting anything, but I found a way around it. Thanks for the help though, guys!

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 61 guests