Jump to content

Find Next Pixel


 Share

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!

Link to comment
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)
$VIRTUALDESKTOPWIDTH = $VIRTUALDESKTOPWIDTH[0]
$VIRTUALDESKTOPHEIGHT = DLLCall("user32.dll","int","GetSystemMetrics","int",$SM_VIRTUALHEIGHT)
$VIRTUALDESKTOPHEIGHT = $VIRTUALDESKTOPHEIGHT[0]

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

HotKeySet("{TAB}","cont")
HotKeySet("{ESC}","quit")

find($color)

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

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

Func cont()
    $bCont = True
EndFunc

Func quit()
    Exit
EndFunc
Thanks! Edited by Larry
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...