Sign in to follow this  
Followers 0
Vahiki

Timeout after While?

9 posts in this topic

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

Share this post


Link to post
Share on other sites



What's your definition for timeout? I think sleep() do that - it stops the script for a defined time. Or what you want to do?


Best Regards BugFix  

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Sorry for being unclear.

I meant that it would only repeat for a certain amount of seconds, is that possible?

And thanks for the tidy-uping :P

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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]

Share this post


Link to post
Share on other sites

THanks! worked like a charm! :P

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

Thanks again then :P

Share this post


Link to post
Share on other sites

You are welcome... glad it worked for you.


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

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