Jump to content
Sign in to follow this  

Find next pixel ?

Recommended Posts


Hello guys am triying to fin more than 1 pixel of same colors. 

here is my code

$1 = PixelSearch(0,0,1365,767,"0x50BA0F")
if IsArray($1) = true Then

and when i find that pixel? move to OTHER same color pixel. and that continously.. is there a way ? i use this image to make my proves


sorry my bad english guys i speak spanish

Share this post

Link to post
Share on other sites

This example appears to be working ok.
The mouse stops moving when they are no 0x50BA0F coloured pixels to right on the same line nor below the stopped mouse pointer.

Press the Esc button to exit at any time.

Opt("WinTitleMatchMode", -2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("PixelCoordMode", 2) ;1=absolute, 0=relative, 2=client
Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client

HotKeySet("{ESC}", "Terminate") ; Press Esc to exit

ShellExecute("circles.jpg") ; Image is in same directory as script, otherwise, use full path name of image file.
Local $hWin = WinWaitActive("circle", "")
Local $aWinPos = WinGetPos("circle", "")
Local $aCtrlPos = ControlGetPos("circle", "", "")
;ConsoleWrite($aCtrlPos[0] & ", " & $aCtrlPos[1] & ", " & $aCtrlPos[2] & ", " & $aCtrlPos[3] & @LF)
;ConsoleWrite($aWinPos[2] & " " & $aWinPos[3] & @LF)
Local $x, $y, $a = PixelSearch(0, 0, $aWinPos[2], $aWinPos[3], "0x50BA0F", 0, 1, $hWin)
If @error Then
    Exit ; Colour does not exit in image, so exit.
    $x = $a[0]
    $y = $a[1]
;ConsoleWrite($aWinPos[3] + $aWinPos[1] & @LF)
;$y = $aCtrlPos[3]*0.95  ; For testing near end of image.

While ($y <= $aCtrlPos[3])
    $a = PixelSearch($x, $y, $aWinPos[2], $y, "0x50BA0F", 0, 1, $hWin) ; Searching one horizontal line at a time.
    If @error Then ;If colour not found, start at the beginning of a new, next line.
        $y += 1
        $x = 0
        MouseMove($x, $y, 0)
        $x = $a[0] + 1
    ;ConsoleWrite("Mouse Position: " & $x & ", " & $y & @CRLF)

Func Terminate()
EndFunc   ;==>Terminate

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this