Jump to content
Sign in to follow this  
Engineer

timing and delay

Recommended Posts

Engineer

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

Share this post


Link to post
Share on other sites
hannes08

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]

Share this post


Link to post
Share on other sites
monoscout999

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

Share this post


Link to post
Share on other sites
wakillon

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

Share this post


Link to post
Share on other sites
MvGulik

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

Share this post


Link to post
Share on other sites
hannes08

Hi Engineer

Take a look at Adlib*() functions in the help file.

Why don't you want to start your program over scheduled tasks?


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.