Jump to content

pixelsearch with pixelchecksum


Recommended Posts

Hello all. My problem is this: When I search my screen for a particular color of a pixel and then check the surrounding values to verify that I have indeed found the correct pattern, my program gets stuck re-checking the same pixel over and over. How do I make it skip over that pixel and find the others on the screen?

Thanks

PixelSearch(0,0,@DesktopWidth,@DesktopHeight,$colorSearch)
while @error = 0
$var = PixelSearch(0,0,@DesktopWidth,@DesktopHeight,$colorSearch)
$sumcheck = PixelChecksum($var[0]-2,$var[1]-2,$var[0]+2,$var[1]+2)
MsgBox(0,"Sum is ",$sumcheck)
if $sumcheck = $sumcalc Then
    MsgBox(0,"found one",$var[0]&","&$var[1])
EndIf
WEnd
Link to comment
Share on other sites

Change the area you are searching according to the results of your first search; to do this use the coordinates found from the first search for the second search.

Example:

$FirstWhiteFound = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xFFFFFF) ;Search for white pixel.
If Not @error Then
    If PixelGetColor($FirstWhiteFound[0] + 1, $FirstWhiteFound[1]) <> 0xFFFFFF Then ;If the pixel to the right it isn't white.
        $SecondWhiteFound = PixelSearch($FirstWhiteFound[0] + 1, $FirstWhiteFound[1], @DesktopWidth, @DesktopHeight, 0xFFFFFF) ;Start search one pixel to the right.
        If not @Error Then MsgBox(0, "Success", "Found second instance of 0xFFFFFF")
    EndIf
Else
    MsgBox(0, "Error", "Couldn't find 0xFFFFFF")
EndIf
Edited by BitByteBit
Link to comment
Share on other sites

Change the area you are searching according to the results of your first search; to do this use the coordinates found from the first search for the second search.

Example:

$FirstWhiteFound = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xFFFFFF) ;Search for white pixel.
If Not @error Then
    If PixelGetColor($FirstWhiteFound[0] + 1, $FirstWhiteFound[1]) <> 0xFFFFFF Then ;If the pixel to the right it isn't white.
        $SecondWhiteFound = PixelSearch($FirstWhiteFound[0] + 1, $FirstWhiteFound[1], @DesktopWidth, @DesktopHeight, 0xFFFFFF) ;Start search one pixel to the right.
        If not @Error Then MsgBox(0, "Success", "Found second instance of 0xFFFFFF")
    EndIf
Else
    MsgBox(0, "Error", "Couldn't find 0xFFFFFF")
EndIf

Thank you very much.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...