Jump to content

Error Handling Troubles


Drew
 Share

Recommended Posts

Alright I've been touching up my script with some error handling... well , I'm having some troubles.

I have it search for a color , and if it ends up @error = 1 , than do whatever it was to produce what it was looking for ...again.

But the script stops there. It doesn't look again etc.

Here's an example of what I mean:

I you would take a look at the first IF statement , that's the first error checking. It's searching for a blue pixel , and if it finds it , then it moves on... but if it doesn't , it does the previous step again. This is in hopes that it will find the blue pixel this time... but the script just stops... it doesn't look for the blue pixel again.

I was thinking that I might have to include some While statements or something so that it keeps doing it until it finds it.

Func _B()
    Sleep(1500)
    WinActivate("Windows Internet Explorer")
    MouseClick("left", $Var1, $Var2, 1, 10)
    MouseClick("left", $Var1, $Var2, 1, 10)
    Sleep(1000)
    MouseClick("left", $R1, $R2, 1, 10)
    _IELoadWait($oIE)
    Sleep(1000)
    $Check = PixelSearch(146, 353, 268, 406, 0x39599c)

    If @error = 1 Then
    ;MsgBox( 0, "Problem", "Not at the right screen.")
        Sleep(1000)
        MouseClick("left", $R1, $R2, 1, 10)
        _IELoadWait($oIE)
        MouseClick("left", $R1, $R2, 1, 10)
        MouseClick("left", 271, 245, 1, 0)
    Else
        Sleep(1000)
        MouseClick("left", $R1, $R2, 1, 10)
        Sleep(1000)
        MouseClick("left", $R1, $R2, 1, 10)
        _IELoadWait($oIE)
        Sleep(1000)
        $DClick = PixelSearch(515, 348, 632, 413, 0x39599C)

        If @error = 1 Then
            Sleep(1000)
            MouseClick("left", $R1, $R2, 1, 10)
            Sleep(1000)
            MouseClick("left", $R1, $R2, 1, 10)
            Sleep(1000)
        Else
            MouseClick("left", 573, 376, 1, 0)
            Sleep(2000)
            $S = PixelSearch(126, 313, 227, 353, 0xFF7D00)
            If @error = 1 Then
                MsgBox(0, "No Orange", "Somethings wrong. Orange cannot be found.")
                Sleep(1000)
                MouseClick("left", $R1, $R2, 1, 10)
                Sleep(1000)
                MouseClick("left", 573, 376, 1, 0)
                Sleep(1000)
            Else
                MouseClick("left", $m1, $m2, 1, 0)
            EndIf
        EndIf
    EndIf
EndFunc  ;==>_B

Any help is greatly appreciated =(.

Thanks,

*Drew

Link to comment
Share on other sites

It just hit me , Do and Until statements.

But to be quite honest... I have no idea how to use them , so any support would still be very useful. I will resort back to the helpfile , but remain refreshing this to see if anyone replies.

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...