Jump to content
Sign in to follow this  
Vahiki

Timeout after While?

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

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

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

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  

×
×
  • Create New...