Sign in to follow this  
Followers 0
Engineer

pixle search blues.

4 posts in this topic

well, I'm back with another obviously easy question that I have no clue how to go about. basicly, I'd like it to search for a pixle in a certian area, then refine that search for the same color in a smaller area. it should move the mouse if it sees it, but I keep getting a error message that says you need endif's. I have no Idea where to put them, or how to go about it. some help would be apricated.

PixelSearch( 469, 417, 514, 458, 0xbe3137, 10 )
If Not MsgBox(1, "nothing", "can't see nothing", 10) Then
    PixelSearch( 472, 421, 484, 432, 0xbe3137, 10  )
If not MsgBox(1, "well, its not here", "saw it, lost it", 5) Then
    mousemove( 200, 200, 100 )
EndIf

Share this post


Link to post
Share on other sites



Your first If-statement is missing an EndIf. It should be:

If Not MsgBox(1, "nothing", "can't see nothing", 10) Then

PixelSearch( 472, 421, 484, 432, 0xbe3137, 10 )

EndIf

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

His entire script is going to fail, honestly.

Not only is there a lack of EndIf statements, the syntax for the If statements are wildly off.

Perhaps a more full example of your script, please? Because if you have a problem with this basic stuff, then your code is going to look like spaghetti.

Edit: Took a best guess at what you're looking for.

$aReturn = FindPixel(453, 436, 1243, 1492, 0xffffff) ; go into custom function and store the return in a variable.

If Not IsArray($aReturn) Then ; check the return.  If it's an array, than we're golden.
    ConsoleWrite("Didn't find it after (roughly) 10 seconds" & @CRLF) ; write to the console window in SciTE editor.  Faster than MSGBOX()
Else
    ConsoleWrite("Found it!" & @CRLF)
EndIf


Func FindPixel($iLeft, $iTop, $iRight, $iBottom, $hColor, $iVar = 0, $iStep = 1)
    Local $iDelay = 1000 ; 1000 loops = roughly 10 seconds
    Local $iCount = 0, $aResult = ""
    While 1
        $iCount += 1
        Sleep(10)
        $aResult = PixelSearch($iLeft, $iTop, $iRight, $iBottom, $hColor, $iVar, $iStep) ; Store the result in a variable
        If IsArray($aResult) Then ; Check for array.  If so, we're golden.
            SetError(0)
            Return 1
        Else
            ContinueLoop
        EndIf
        If $iCount > $iDelay Then ; crash out if more than $iDelay iterations
            SetError(1)
            $aResult = "" ; set $aResult to empty string
            Return $aResult
        EndIf
    WEnd
EndFunc   ;==>FindPixel
Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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  
Followers 0