How to compare 2 pixels location?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kauzds
Posts: 5
Joined: 17 Jan 2018, 16:52

How to compare 2 pixels location?

20 Jan 2018, 03:18

I am getting 2 pixels with Pixelsearch. I want to compare these two pixels and if they are at a X pixel range of each other I want to do something. How can I do that?


Here is an exemple:

Code: Select all

PixelSearch, P1x, P1y, 0, 0, 500, 500, Color1, 20, RGB
	if ErrorLevel
		MsgBox, Color1 not found
	else
		continue
		
PixelSearch, P2x, P2y, 0, 0, 500, 500, Color2, 20, RGB
	if ErrorLevel								
		MsgBox, Color2 not found
	Else
;		== Comparation here ==
		if Color2 is at 30 pixel or closer to Color 1
		DO something
Color1 and Color2 will have a hexdecimal color value each ofcourse
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: How to compare 2 pixels location?

20 Jan 2018, 06:33

PixelSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ColorID [, Variation, Fast|RGB]
User avatar
noname
Posts: 516
Joined: 19 Nov 2013, 09:15

Re: How to compare 2 pixels location?

20 Jan 2018, 06:44

If you mean act when distance difference is less than 30 ( or you want color values difference....it is a bit ambigous)

example tooltip is ok when mouse is within 30 pixels of screen center.

Code: Select all

#Persistent 
p1x:=a_screenwidth//2
p1y:=a_screenheight//2
coordmode,mouse
CoordMode, pixel

SetTimer, alert,250
return

alert:
mousegetpos,p2x,p2y
if (Abs(p1x-p2x)<30 and Abs(p1y-p2y)<30)
tooltip ok
else
tooltip out of range
return

esc::exitapp

Code: Select all

Pixelsearch, p1x,py1,0,0,500,500,color1,20,rgb
if errorlevel
  {
  msgbox not found
  return
  }
else
Pixelsearch, p2x,py2,0,0,500,500,color2,20,rgb
if errorlevel
  {
  msgbox not found
  return
  }
else if (Abs(px1-px2)<30 and Abs(py1-py2)<30)
tooltip ok
else
tooltip out of range
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: GEOVAN, Google [Bot], Spelth and 132 guests