dassksnz 0 Posted December 20, 2010 How do u make a timer so it will do one thing every say 1min then do it again in a 1min time and so on. how is that done in autoit Share this post Link to post Share on other sites
schuc 0 Posted December 20, 2010 Take a look at TimerInit() and TimerDiff(). Here is an example: $begin = TimerInit() sleep(3000) $dif = TimerDiff($begin) MsgBox(0,"Time difference is",$dif) Share this post Link to post Share on other sites
dassksnz 0 Posted December 20, 2010 Take a look at TimerInit() and TimerDiff(). Here is an example: $begin = TimerInit() sleep(3000) $dif = TimerDiff($begin) MsgBox(0,"Time difference is",$dif) i want it to for example type the same thing in on notepad every 5second how can i do that? is that what TimerInit() and TimerDiff() does? Share this post Link to post Share on other sites
kaotkbliss 146 Posted December 20, 2010 TimerInit() and TimerDiff() together works like a stop watch. TimerInit() starts the timer, TimerDiff() gives you the amount of time that has passed since TimerInit() was called. For your project, a simple Sleep(5000) will work. (Sleep is in miliseconds) So, While 1 ;do your thing Sleep(5000);5 seconds Wend 010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueekWe're gonna need another Timmy! Share this post Link to post Share on other sites
dassksnz 0 Posted December 20, 2010 thanks is it worked how i wanted. just a question is there a way of stoping or pausing the script the script by pressing a key on the key board eg. Ctrl + 1 or something. Share this post Link to post Share on other sites
kaotkbliss 146 Posted December 20, 2010 Check out HotKeySet() in the helpfile, there is an example there of how to create a pause key for your script. 010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueekWe're gonna need another Timmy! Share this post Link to post Share on other sites
MvGulik 86 Posted December 20, 2010 AdlibRegister "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)"Believing what you know ain't so" ...Knock Knock ... Share this post Link to post Share on other sites
NiVZ 1 Posted December 22, 2010 Try this: expandcollapse popup; Set Paused to false Global $Paused = False ; Set the Pause hotkey to Ctrl + 1 HotKeySet("^1", "TogglePause") ; Start the timer Global $TimeStart = TimerInit() ; Run forever While 1 If $Paused Then Do Until $Paused = False EndIf ; Check how long has passed $TimeElapsed = TimerDiff($TimeStart) ; Check if the time elapsed is longer than a minute (60000 milliseconds) If $TimeElapsed >= 60000 Then ; Tell the user a minute has passed MsgBox(0, "", "A minute has passed") ; Reset the timer $TimeStart = TimerInit() EndIf WEnd Func TogglePause() If $Paused = False Then $Paused = True MsgBox(0, "", "Paused") Else $Paused = False MsgBox(0, "", "UnPaused") ; Reset the timer to stop it from triggering immediately after coming out of pause $TimeStart = TimerInit() EndIf EndFunc NiVZ Share this post Link to post Share on other sites
MvGulik 86 Posted December 24, 2010 (edited) TimerInit() and TimerDiff() together works like a stop watch. TimerInit() starts the timer, TimerDiff() gives you the amount of time that has passed since TimerInit() was called.Don't really like this explanation as it suggest something thats not corrects.- There is just one general cpu-timer running on your computer, and its running all the time. (Actually ... some cpu's don't have one but thats a different matter. + Ignoring potential multi core exception.)- TimerInit() just picks up (and returns) the current time value of that cpu-timer at the moment TimerInit() is used.- TimerDiff() will also pick up the current cpu-time value, and compare that new value to the other one that you put into TimerDiff(<OtherOlderCpuTimeValue>)). And returns the difference between those two values ... in Milliseconds. (1/1000sec)Thats all. Edited December 24, 2010 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)"Believing what you know ain't so" ...Knock Knock ... Share this post Link to post Share on other sites
Gobinath 0 Posted June 16, 2011 Sample Timer Code ;4.25 local $dif1 ="00" local $dif2 ="00" local $dif3 ="00" While 1 $begin = TimerInit() sleep(1000) $dif = (Round(TimerDiff($begin)/1000)) $dif1 = $dif1+$dif if $dif1 = 60 Then $dif1 = 0 $dif2=$dif2+1 if $dif2<10 Then $dif2 = "0"&$dif2 Endif if $dif2 = 60 Then $dif1 = 0 $dif2 = 0 $dif3=$dif3+1 if $dif3<10 Then $dif3 = "0"&$dif3 Endif EndIf EndIf If $dif1 < 10 Then $dif1 = "0"&$dif1 ;MsgBox(4096,"",$dif1) ConsoleWrite("*"&$dif3&"."&$dif2&"."&$dif1&@CRLF) Else ConsoleWrite("*"&$dif3&"."&$dif2&"."&$dif1&@CRLF) EndIf Wend Share this post Link to post Share on other sites
MvGulik 86 Posted June 16, 2011 Right ... stick to newer topic's if you don't want others to spot that you are just upping your post count.... And learn how to use the available forum features, like, well, code tags perhaps. "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)"Believing what you know ain't so" ...Knock Knock ... Share this post Link to post Share on other sites