Jump to content
Sign in to follow this  

Find Next Pixel

Recommended Posts

Hi guys!

I'm trying to write a program that searches for a pixel which has a hex value exactly equal to what a user types into a gui.

So far, what I have been able to do is to have the gui minimise itself, find the pixel, move the mouse to that posisiton, and store that position into an array.

Now, it also enables a "Find Next" button. I want the next loop to work so that it will start searching the screen again, from top to bottom on the following conditions:

1.Pixels found before are ignored

2.Pixels within 5 pixels up, down, left, and right are also ignored.

What this in effect does is that it keeps searching the screen for the pixels from top to bottom, left to right, searching those pixels until it reaches the very end of the screen.

Any ideas on how to do that?

Thanks guys!

Share this post

Link to post
Share on other sites

I whipped this up...

Global Const $SM_VIRTUALWIDTH = 78
Global Const $SM_VIRTUALHEIGHT = 79
Global $bCont = False

$VIRTUALDESKTOPWIDTH = DLLCall("user32.dll","int","GetSystemMetrics","int",$SM_VIRTUALWIDTH)
$VIRTUALDESKTOPHEIGHT = DLLCall("user32.dll","int","GetSystemMetrics","int",$SM_VIRTUALHEIGHT)

$color = InputBox("Color","Color to find: e.g. FF00FF")
$color = Dec($color)



MsgBox(4096,"Color","Done finding colors.")

Func find($pixel)
    $x = 0
    $y = 0
    While 1
        $xy = PixelSearch($x,$y,$VIRTUALDESKTOPWIDTH - 1,$ypixel,$pixel)
        If @error And $ypixel = ($VIRTUALDESKTOPHEIGHT - 1)Then
        ElseIf @error Then
            $y = $ypixel + 1
            $ypixel = ($VIRTUALDESKTOPHEIGHT - 1)
            $x = 0
            ToolTip("PRESS [TAB] to continue, [ESC] to quit.")
            While Not $bCont
            $bCont = False
            $y = $xy[1]
            $ypixel = $y
            $x = $xy[0] + 1

Func cont()
    $bCont = True

Func quit()
Thanks! Edited by Larry

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...