Jump to content
Sign in to follow this  
keyserSoze15

pixelsearch with pixelchecksum

Recommended Posts

keyserSoze15

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

Share this post


Link to post
Share on other sites
BitByteBit

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

Share this post


Link to post
Share on other sites
keyserSoze15

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.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.