socap Posted December 30, 2011 Share Posted December 30, 2011 Sleep(2 * 59.1 * 1000) Next I can't make next every 2 minutes precisely Help please, instead of this sleep, sleep it sleeps for two minutes of earth time. I mean it should sleep till 2 minutes on clock pass. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 30, 2011 Developers Share Posted December 30, 2011 Test with @Min. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
kylomas Posted December 30, 2011 Share Posted December 30, 2011 socap, This is the routine that I use. #include <date.au3> Local $stime = _nowcalc(), $i = 0 While $i < 2 Sleep(1000) ; sleep for a sec $i = _datediff('n',$stime,_nowcalc()) wend Good Luck! kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
ripdad Posted December 31, 2011 Share Posted December 31, 2011 Sleep((60000 * 2) - (@SEC * 1000)) "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
autoitter Posted December 31, 2011 Share Posted December 31, 2011 I've once made a clock that would update the display every second. I used sleep this way: While True UpdateDisplay() ; Wait until next second pass Sleep(1000-@MSEC) WEnd Link to comment Share on other sites More sharing options...
bogQ Posted December 31, 2011 Share Posted December 31, 2011 (edited) or maybe something more complicated currently set to react on every second (func taken from monoceres example on 'Sleep down to 100 Nano seconds') but as Jos pointed @Min is probably what OP need $hDll=DllOpen("ntdll.dll") $hStruct=DllStructCreate("int64 time;") $s = @SEC Do DllStructSetData($hStruct,"time",-1*(1*10)) DllCall($hDll,"dword","ZwDelayExecution","int",0,"ptr",DllStructGetPtr($hStruct)) Until $s <> @SEC $a = TimerInit() For $x = 1 To 100 Do DllStructSetData($hStruct,"time",-1*(1*10)) DllCall($hDll,"dword","ZwDelayExecution","int",0,"ptr",DllStructGetPtr($hStruct)) $t = TimerDiff($a) Until $t > 1000*$x ConsoleWrite($t&' Sec = '&@SEC&@CRLF) Next DllClose($hDll) Edited December 31, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
kylomas Posted January 1, 2012 Share Posted January 1, 2012 @ripdad, is Sleep((60000 * 2) - (@SEC * 1000)) the same as sleep(120-@sec) neither of which will work in a loop unless you use a variable that is decreased with each iteration. @jos, I see @min used frequently. Do you not get less than 1 full minute though, depending on when the @min macro is invoked? And there is the problem of crossing an hour boundry. Just my 2 cents, gentlemen. Happy New Year, kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
ripdad Posted January 1, 2012 Share Posted January 1, 2012 (edited) Well, I suppose it's a matter of interpretation of the OP, which I could have misinterpreted. It appears, with the given information of the OP, that he wants to pause a For Loop for 2 minutes to the top of that 2 minutes (real clock time), which would be 2:00, for instance. I could be wrong. This... Sleep((60000 * 2) - (@SEC * 1000)) Sleeps for 2 minutes minus the spent clock seconds of that 2 minutes. Which becomes apparent at 2:00. and this ... Sleep(120-@sec) Sleeps for 120 milliseconds minus the spent clock seconds? Max number for @SEC is 59. Some additional math would be needed, I think. And a Happy New Year to you too and to all the AutoIt Community! Edited January 1, 2012 by ripdad "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
kylomas Posted January 1, 2012 Share Posted January 1, 2012 ripdad, You are right, my mistake! kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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