epicfail Posted September 25, 2009 Share Posted September 25, 2009 how would i have a while loop end after 10 min so after to min it sends exitloop or something? Link to comment Share on other sites More sharing options...
jvanegmond Posted September 25, 2009 Share Posted September 25, 2009 (edited) $init = TimerInit() While TimerDiff($init) < .. whatever value here for 10 minutes ; normal code here: ) Wend Edited September 25, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 25, 2009 Author Share Posted September 25, 2009 wow sweet that was fast. $init = TimerInit(10) While TimerDiff($init) < .. whatever value here for 10 minutes If WinActive("Untitled - Notepad") Then ExitLoop EndIf Wend so is that right if it dont find notepad withen 10 min it will end the loop? Link to comment Share on other sites More sharing options...
jvanegmond Posted September 25, 2009 Share Posted September 25, 2009 You're close.. 1. TimerInit does not take parameters 2. You still need to replace ".. whatever value here for 10 minutes" for a return value from TimerDiff that matches 10 minutes .. github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 25, 2009 Author Share Posted September 25, 2009 (edited) so that right? There isnt really that much help in the help file about this. $init = TimerInit() While TimerDiff($init) = 10 If WinActive("Untitled - Notepad") Then ExitLoop EndIf Wend Edited September 25, 2009 by epicfail Link to comment Share on other sites More sharing options...
jvanegmond Posted September 25, 2009 Share Posted September 25, 2009 Not even close. Read the help file on TimerDiff. github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 25, 2009 Author Share Posted September 25, 2009 it dosnt really say much in there 2 work with a loop Link to comment Share on other sites More sharing options...
Bert Posted September 25, 2009 Share Posted September 25, 2009 Read on how to do a loop, then read on TimerDiff. Then combined the 2. If this is too much to understand, take the AutoIt 1 2 3 class and look at the AutoIt videos on YouTube. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
jvanegmond Posted September 25, 2009 Share Posted September 25, 2009 (edited) I'll explain it. It's not really specific to the looping.TimerDiff returns the time difference (in milliseconds) from a previous call to TimerInit().For example we have this script:$init = TimerInit() While TimerDiff($init) <= 1000 Sleep(100) WendThis script will make 10 loops. Why?First loop 0ms, second loop 100ms, third loop 300ms, fourth loop 400ms. Then loop 10 = 1000ms, loop 11 = 1100ms but that's too much. 1100 <= 1000 is False.So what you need to do now is correct your script, so that the value that the time difference must be smalelr than 10 minutes expressed in milliseconds.@Volly, epicfail is a little slow to understand. He has the ability to understand many things, but just doesn't see the connection between some things. He needs some special help. 8) Edited September 25, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 25, 2009 Author Share Posted September 25, 2009 i was doing some playing around and came up with this not sure what 1 is right both seem to work. What 1 is the right way? $init = TimerInit() While TimerDiff($init) < 600000 If WinActive("Untitled -") Then ExitLoop EndIf Wend $init = TimerInit() While TimerDiff($init) < 600000 If WinActive("Untitled -") Then ExitLoop EndIf If TimerDiff($init) > 600000 Then ExitLoop EndIf Wend Link to comment Share on other sites More sharing options...
jvanegmond Posted September 25, 2009 Share Posted September 25, 2009 The top one is correct. The bottom one does the check twice per loop, which is unnecesary. : ) github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 25, 2009 Author Share Posted September 25, 2009 sweet thanks 4 the help so how would i exit the script with Exit after that time not just exit the loop? Link to comment Share on other sites More sharing options...
jvanegmond Posted September 25, 2009 Share Posted September 25, 2009 (edited) $init = TimerInit() While TimerDiff($init) < 600000 If WinActive("Untitled -") Then ExitLoop EndIf Wend Exit Or $init = TimerInit() While 1 If TimerDiff($init) > 600000 Then Exit ; Note this says > 600000 instead of < 600000 EndIf If WinActive("Untitled -") Then ExitLoop EndIf Wend Exit Edited September 25, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 25, 2009 Author Share Posted September 25, 2009 ty it took ages but i understand now sorry guys 4 taking awhile to understand. Thanks heaps Manadar u always seem to help me. Link to comment Share on other sites More sharing options...
TurionAltec Posted September 25, 2009 Share Posted September 25, 2009 I added a sleep in there so the CPU doesn't go crazy. $init = TimerInit() While TimerDiff($init) < 600000 If WinActive("Untitled -") Then ExitLoop EndIf Sleep(50) Wend Exit Or $init = TimerInit() While 1 If TimerDiff($init) > 600000 Then Exit ; Note this says > 600000 instead of < 600000 EndIf If WinActive("Untitled -") Then ExitLoop EndIf sleep(50) Wend Exit Link to comment Share on other sites More sharing options...
epicfail Posted September 25, 2009 Author Share Posted September 25, 2009 ok something else say i have other stuff after my while that i dont want to be done after i exit my loop how would i stop it from doing them? if i use exit it will exit but i want to be able to use my gui still so dont want to fully exit the program. Link to comment Share on other sites More sharing options...
jvanegmond Posted September 25, 2009 Share Posted September 25, 2009 ; GUI stuff $result = _WaitForWindow() If $result = 1 Then ; The window was found Else ; There was a time out EndIf Func _WaitForWindow() Local $init = TimerInit() While TimerDiff($init) < 600000 If WinActive("Untitled -") Then Return 1 EndIf Wend Return 0 EndFunc github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 25, 2009 Author Share Posted September 25, 2009 sweet thanks. Link to comment Share on other sites More sharing options...
jvanegmond Posted September 25, 2009 Share Posted September 25, 2009 I hope you have learned some things from this thread. May I ask, what are you building? I've helped you on so many occasions it's made me curious. : ) github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 25, 2009 Author Share Posted September 25, 2009 (edited) a bot 4 a facebook game lol just wanted to try to learn something new. hehe now i have just learnt how to use this to make error ini and send it to a webhost. Edited September 25, 2009 by epicfail 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