mmoalem

25 hours check

6 posts in this topic

Hi there all - another day another question :)

SO I have a set of commands in the script which I want to run in 25 hours interval and I am finding it tricky...

At the end of the script I have a Sleep command for the remaining of the time to the 25 hours endline - I am trying to work out how to read the date/time at the beginning of the script than at the end calculate how much time passed and add whatever amount of seconds needed to sllep for the 25 hours to pass... please if you can point me in the direction...

Share this post


Link to post
Share on other sites



mmoalem,

I would not use Sleep at all. I would run _NowCalc as the task begins and then use _DateDiff to get a value for the next run time. Then run a check in the idle loop which gets the  _NowCalc value at regular intervals (depending on the accuracy you require) until it matches the required value.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks for the help Melba! your suggestion does the job perfectly but I'm courious why not Sleep? Accuracy is not important in this case and I use the Sleep to have a visual countdown on ToolTip to know how long till it starts again...

 so thats what I came up with is:

 

While 1

$startRunTime = _NowCalc()

; script goes here....

$SecondsPassed = _DateDiff('s', $startTimer, _NowCalc())

$MilliSecondsLeftTo25hrs = 90000000-$SecondsPassed*1000

Sleep ($MilliSecondsLeftTo25hrs)

WEnd

Does it look right?

Share this post


Link to post
Share on other sites

mmoalem,

You could make it a little bit simpler:

While 1

    $nBegin = TimerInit()
    
    ; script goes here.... 

    $MilliSecondsLeftTo25hrs = 25 * 60 * 60 * 1000 - Int(TimerDiff($nBegin))

    Sleep($MilliSecondsLeftTo25hrs)

WEnd

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks Melba23 for the script, I was just wondering about the resources use under the two different scripts - if i understand right a timer will be consuming cpu cycles throughout the script run while the nowcalc method will only use cpu cycles on fetching the time... probably very little difference in real terms but wondered if it is the most efficient way... I am a complete beginner so please forgive me if it is stupid concern...

Share this post


Link to post
Share on other sites

mmoalem,

I have several compiled AutoIt executables running permanently - as long as you put a Sleep(10)  in any loops (remember that GUIGetMsg does that for you automatically) they do not seem to interfere in the smooth running of my machine. I believe that you are worrying unnecessarily.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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