Pixel search in diffeent coordinates

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
anobayan
Posts: 5
Joined: 22 Sep 2018, 04:58

Pixel search in diffeent coordinates

23 Sep 2018, 23:33

CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 896, 221, 896, 221, 0x3A6EA5, 0, Fast RGB
If ErrorLevel = 0
{
Click, 1284, -669 Left, 1
Sleep, 10
}
That script will only search and check at coordinate X=896 Y=221.



What i want is, it will search and check on other different coordinates too x=291,y=295 and x=450, y=700 and x=920, y=300 and so on.
buttshark
Posts: 62
Joined: 22 Apr 2017, 20:57

Re: Pixel search in diffeent coordinates

24 Sep 2018, 00:49

Since you are only checking one pixel, you could use PixelGetColor and see if any of the points are the color you are looking for

Code: Select all

CoordMode, Pixel, Window
PixelGetColor, clr1, 896, 221, RGB
PixelGetColor, clr2, 291, 295, RGB
PixelGetColor, clr3, 450, 700, RGB
PixelGetColor, clr4, 920, 300, RGB
if(clr1 == 0x3A6EA5 OR clr2 == 0x3A6EA5 OR clr3 == 0x3A6EA5 OR clr4 == 0x3A6EA5)
{
	Click, 1284, -669 Left, 1
	Sleep, 10
}
I have no idea what I'm doing.
anobayan
Posts: 5
Joined: 22 Sep 2018, 04:58

Re: Pixel search in diffeent coordinates

24 Sep 2018, 02:28

Hi Thank you so much for helping me.

i would be so happy if you could help me too with this one. '
Image
The blue dot will be spawning randomly inside the square.
I need to left click mouse when blue dot is inside the circle.
Ignore when the blue dot appear outside the circle.

What is the easiest action/script to to this?

instead of doing this
CoordMode, Pixel, Window
PixelGetColor, clr1, 896, 221, RGB
PixelGetColor, clr2, 291, 295, RGB
PixelGetColor, clr3, 450, 700, RGB
PixelGetColor, clr4, 920, 300, RGB
if(clr1 == 0x3F48CC OR clr2 == 0x3F48CC OR clr3 == 0x3F48CC OR clr4 == 0x3F48CC)
{
Click, 1284, -669 Left, 1
Sleep, 10
}
instead of putting all the pixel coordinates
is there any easier way, that will it search inside the circle area?
buttshark
Posts: 62
Joined: 22 Apr 2017, 20:57

Re: Pixel search in diffeent coordinates

24 Sep 2018, 13:17

In this case, I would PixelSearch in the square, and use math on the found location to see if it's in the circle.

Code: Select all

;update coordinates to top left of square and bottom right of square
x1 := 100
y1 := 100
x2 := 200
y2 := 200

PixelSearch, x, y, %x1%, %y1%, %x2%, %y2%, 0x3A6EA5,, Fast RGB
if(!ErrorLevel AND inCircle(x, y, (x2 + x1) / 2, (y2 + y1) / 2,  (x2 - x1) / 2))
	Click, %x%, %y%
return

inCircle(x, y, centerX, centerY, radius)
{
	return sqrt((x - centerX) ** 2 + (y - centerY) ** 2) < radius
}
I have no idea what I'm doing.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 391 guests