Vahiki Posted December 25, 2006 Share Posted December 25, 2006 Im new to AutoIt and I need to have a timeout after the While function, is this possible?Script:CODESleep(5000)while 1=1Opt('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)WEndWEndWEnd Link to comment Share on other sites More sharing options...
BugFix Posted December 25, 2006 Share Posted December 25, 2006 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 Link to comment Share on other sites More sharing options...
Zedna Posted December 25, 2006 Share Posted December 25, 2006 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 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Vahiki Posted December 25, 2006 Author Share Posted December 25, 2006 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 Link to comment Share on other sites More sharing options...
herewasplato Posted December 25, 2006 Share Posted December 25, 2006 (edited) untestedSleep(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 December 25, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Vahiki Posted December 25, 2006 Author Share Posted December 25, 2006 THanks! worked like a charm! Link to comment Share on other sites More sharing options...
herewasplato Posted December 25, 2006 Share Posted December 25, 2006 THanks! worked like a charm! 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 More sharing options...
Vahiki Posted December 25, 2006 Author Share Posted December 25, 2006 Thanks again then Link to comment Share on other sites More sharing options...
herewasplato Posted December 27, 2006 Share Posted December 27, 2006 You are welcome... glad it worked for you. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now