Searches a rectangle of pixels for the pixel color provided.
PixelSearch ( left, top, right, bottom, color [, shade-variation [, step [, hwnd]]] )
| left | left coordinate of rectangle. |
| top | top coordinate of rectangle. |
| right | right coordinate of rectangle. |
| bottom | bottom coordinate of rectangle. |
| color | Colour value of pixel to find (in decimal or hex). |
| shade-variation | [optional] A number between 0 and 255 to indicate the allowed number of shades of variation of the red, green, and blue components of the colour. Default is 0 (exact match). |
| step | [optional] Instead of searching each pixel use a value larger than 1 to skip pixels (for speed). E.g. A value of 2 will only check every other pixel. Default is 1. |
| hwnd | [optional] Window handle to be used. |
| Success: | Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y). |
| Failure: | Sets @error to 1 if color is not found. |
; Find a pure red pixel in the range 0,0-20,300
Local $coord = PixelSearch(0, 0, 20, 300, 0xFF0000)
If Not @error Then
MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
EndIf
; Find a pure red pixel or a red pixel within 10 shades variations of pure red
$coord = PixelSearch(0, 0, 20, 300, 0xFF0000, 10)
If Not @error Then
MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
EndIf