Jump to content

Sleep till 2 minutes on clock pass.


socap
 Share

Recommended Posts

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

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 by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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

@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

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 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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...