Jump to content

timing and delay


Recommended Posts

I'd like build a program that regularly opens up a window every 2 hours and then preform actions in that window. the problem is I can's seem to find a timing system for the program. and on that same subject, is there a way to create multiple timers in the GUI? any help on this subject would be apricated

Link to comment
Share on other sites

Hi Engineer,

sure you can set different timers... also take a look at Adlib*() functions.

You could also start your script over scheduled tasks on a regular basis.

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

there many way to doing that. As hannes123 says Adlib function is one of them... when you register the Adlib Function you have to set the time that the function has to wait until executes again... For Ex. AdlibRegister("MyFunc", 1000*60*60*2) will be execute that function every 2 hours...

The time is in miliseconds.. that is the reason of the multiply operations.

1000 ms = 1 second

1 second * 60 = 1 minute

1 minute * 60 = 1 hour

1 hour * 2 = 2 hours

I hope you get it. :mellow:

another ways will be using a loop with a Sleep() command inside of it... or Using Timers, TimerInit() and TimerDiff()

Link to comment
Share on other sites

You can use _DateDiff in your script Loop.

#Include <Date.au3>

Global $_Timer = _NowCalc ( )

While 1
    $_NowCalc = _NowCalc ( )
    If _DateDiff ( "h", $_Timer, $_NowCalc ) >= 2 Then  ; 2 hours
        ConsoleWrite ( "$_NowCalc : " & $_NowCalc & @Crlf )
        $_Timer = $_NowCalc
    EndIf
    Sleep ( 10 )
WEnd

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

the problem is I can's seem to find a timing system for the program.

There are different ways of timing things. Which way is best depend on how and when its used.

For inside a running program. Adlib + TimerInt()&TimerDif + some variable's that contains the timer(s) start point work very nice.

Using a GMT like timestamp(value) or some YY.MM.DD.HH.MM.SS(.XXX) time 'string' are best used when saving and reloading timer data.

is there a way to create multiple timers in the GUI?

Not really ... You just display things in the GUI part. But creating multiple timers is no problem. And displaying them in a GUI is no problem either.

Example(GUI screenshot):

This is just using one adlib function, with a array containing the timer data. (Time start point)

Posted Image

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

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