Jump to content
Sign in to follow this  
seesoe

system time

Recommended Posts

seesoe

is there a way to monitor the system time and do something at say like 10am?

Share this post


Link to post
Share on other sites
SmOke_N

is there a way to monitor the system time and do something at say like 10am?

Sure. There are Macros (@HOUR/@MIN), There are Loops While/WEnd, There are Timer functions (TimerInit()/TimerDiff()), There are functions that can be called to do a callback (AdlibEnable, etc), there's even the good old task scheduler right on your windows system, that you can tell it to call an AutoIt.exe at a specific time.

Plenty of ways.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
seesoe

would there be to much cpu usage if i put this in the main while loop?

if @HOUR == 10 then.

Share this post


Link to post
Share on other sites
SmOke_N

would there be to much cpu usage if i put this in the main while loop?

if @HOUR == 10 then.

Well, you don't need to check every millisecond, only every minute. With that in mind, you could put a
Sleep(60000)
In the While loop as well, so it only checks every minute the hour. You'd have virtually no cpu usage then.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
seesoe

hmmm,

i have a server program i made, while the server is running i need it to run a function at 11 am then at 8pm, the main while loop is for the gui and stuff.

that would be 9 hours so 3240000 ms, i was thinking AdlibEnable, but that might not be sufficient.

Edited by seesoe

Share this post


Link to post
Share on other sites
SmOke_N

hmmm,

i have a server program i made, while the server is running i need it to run a function at 11 am then at 8pm, the main while loop is for the gui and stuff.

that would be 9 hours so 3240000 ms, i was thinking AdlibEnable, but that might not be sufficient.

You've lost me on the need for 3240000 is even there.

If you're using GUIGetMsg() in your loop, then you don't need a sleep, its default sleep is 250 ms, so you won't see any increase if you stick your condition statement in the same loop.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
seesoe

ya i have

While 1

$msg = GUIGetMsg()

so in the loop it would be ok to do

if @HOUR == 11 then
 run_function()
endif

with no cpu overload?

i wanted to run a function at 11am and 8pm, thats 9 hours, and 9 hours in ms is 3240000, however, i just realized i would have to start the program at 11 to use that, so scratch that whole idea

Share this post


Link to post
Share on other sites
SmOke_N

ya i have

While 1

$msg = GUIGetMsg()

so in the loop it would be ok to do

if @HOUR == 11 then
 run_function()
endifoÝ÷ Û­z¦ê/z¹hiØ°j{^+ºvºw-Ú·]Z©Ýò­«lö.®Æ§wØhº»"k"³}¸ÓM4½êâë-­æ¥7
.ØZ½ëh²Ö«¶Ø^¦º ­©·]m¢ë¶­²­«ØZ·hèy¯êº^jëh×6Global $i_hour_one = 11, $i_hour_two = 20, $i_current_hour = 0

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
    EndSwitch
    
    $i_current_hour = Int(@HOUR)
    If $i_current_hour = $i_hour_one Or $i_current_hour = $i_hour_two Then
        ; Make sure we only enter this function once
        If Int(@MIN) = 0 Then
            _Run_HourFunc()
            ; Function is done, but @MIN may still = 0, so do a loop
            ; that will loop until @Min is greater than 0
            ; This will only happen twice a day, 
            ; so there will only be a max of 60 seconds the gui won't be usable each time
            Do
                Sleep(10)
            Until Int(@MIN) > 0
        EndIf
    EndIf
WEnd

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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.