I know how to find 1 pixel that matches my criteria, but the problem is that I would like to find all pixels of specific color and add them to array, so after that I can use it to rand one and "click" on it.
Source code:
Local $aCoord = PixelSearch(0, 0, $clientSize[0], $clientSize[1], 0x09126C, 10, 1, $hWnd)
If Not @error Then
; add to array and search next
Else
GUICtrlSetData($someLabel, "Not Found")
EndIf
I want to find ALL THE PIXELS, not only "the first" one. How can I achieve that? What am I missing?
This can't be done using PixelSearch
because it stops executing when a matching pixel is found.
It can be done by looping PixelGetColor
over your area. Something like:
For $x = 0 To $clientSize[0] Step 1
For $y = 0 To $clientSize[1] Step 1
If PixelGetColor($x,$y,$hWnd) = 0x09126C Then
;Add $x and $y to Array using _ArrayAdd() (or whatever you prefer)
EndIf
Next
Next
This might feel slower than PixelSearch
because it now has to scan the entire area, instead of stopping at the first match, but it shouldn't be, since PixelSearch
is based on the same principle.