Jump to content

Timeout after While?


Vahiki
 Share

Recommended Posts

Im new to AutoIt and I need to have a timeout after the While function, is this possible?

Script:

CODE
Sleep(5000)

while 1=1

Opt('SendKeyDownDelay',1000)

Send("q")

Send("{TAB}")

$var = PixelGetColor(65,43)="0xF86060"

While $var = PixelGetColor(65,43)="0xF86060"

Send("f")

Send("{SPACE}")

Sleep(5000)

$var = PixelGetColor(1053,861)="0x000000"

While $var =NOT PixelGetColor(1053,861)="0x000000"

Send("f")

Send(1)

Sleep(500)

WEnd

$var = PixelGetColor(1133,861)="0x000000"

While $var =NOT PixelGetColor(1133,861)="0x000000" Timout possible here?

Send("f")

Send(3)

Sleep(500)

WEnd

WEnd

WEnd

Link to comment
Share on other sites

Im new to AutoIt and I need to have a timeout after the While function, is this possible?

Here is your script with some Tidy and corrections and possible solution.

But you were unclear with your question, so it's maybe not exactly what you want.

Opt('SendKeyDownDelay',1000)
Sleep(5000)

while 1
    Send("q")
    Send("{TAB}")
    
    While PixelGetColor(65,43) = 0xF86060
        Send("f")
        Send("{SPACE}")
        Sleep(5000)
        
        While PixelGetColor(1053,861) <> 0x000000
            Send("f")
            Send("1")
            Sleep(500)
        WEnd
        
        While PixelGetColor(1133,861) <> 0x000000 ;Timout possible here?
            Sleep(5000) ; is this what you want?
            Send("f")
            Send("3")
            Sleep(500)
        WEnd
        
        Sleep(5000) ; or is that what you want?
    WEnd
WEnd
Link to comment
Share on other sites

untested

Sleep(5000)
While 1
    Opt('SendKeyDownDelay', 1000)
    Send("q")
    Send("{TAB}")
    $var = PixelGetColor(65, 43) = "0xF86060"
    While $var = PixelGetColor(65, 43) = "0xF86060"
        Send("f")
        Send("{SPACE}")
        Sleep(5000)
        $var = PixelGetColor(1053, 861) = "0x000000"
        While $var = Not PixelGetColor(1053, 861) = "0x000000"
            Send("f")
            Send(1)
            Sleep(500)
        WEnd
        $var = PixelGetColor(1133, 861) = "0x000000"
        $timeout = 0
        While $var = Not PixelGetColor(1133, 861) = "0x000000" And $timeout < 10
            Send("f")
            Send(3)
            Sleep(500)
            $timeout &= 1
        WEnd
    WEnd
WEnd
Edit: change or to and

Edit2: attempted to fix font info inside autoit tags after edit of code

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

THanks! worked like a charm! :P

You posted your thanks about the same time as I posted a correction to the code. You might want to use "And" on the While line. Also, you could do the same thing using If $timeout = 10 Then ExitLoop

[size="1"][font="Arial"].[u].[/u][/font][/size]

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