Sign in to follow this  
Followers 0
DeDee

Execute a function at a certain start time and repeat execution for a certain duration

5 posts in this topic

Hi

I'm trying to write a program where I need to have a function executed at a certain start time and then repeat execution for a duration. I tried different combinations, but it does not seem to work. Can you share some ideas please?

Share this post


Link to post
Share on other sites



Look at the time macros, such as @HOUR, @MIN, or _nowTime() in the help file.

Or...

Show what you have tried, even if it doesn't work as you would like it to, or explain more about what you're trying to do with this function, so we can assist. Help us help you ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ok. First of all I tried to use AdlibRegister, and I don't understand how this is really working - though it says that checkes every x min/sec...it checks one time for me. Is AdlibRegister not a good option to solve my problem, or am I not using it correcty?

 

#include <Date.au3>  
$StartTime = "18:24"




AdlibRegister("_Check",1000*60)
$duration=30000


While 1;just idle around
Sleep(1000)
WEnd


Func _Check();every minute we check
$CurrentTime = _NowTime(4);the current time
ConsoleWrite("CurrentTime="&$CurrentTime&"---"&"StartTime="&$StartTime)
If ($CurrentTime == $StartTime) Then


  MsgBox(0, "Test", "Execute my function")


$timer = timerinit()
do
;here will execute function


until timerdiff($timer) >= $duration; 




EndIf


AdlibUnRegister();unregister the running function
Exit;and exit
EndFunc
Edited by DeDee

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I found a solution, but I could not make it work with AdlibRegister() and AdlibUnRegister(). If anyone can explain how to use these functions it would help. :)

while 1
        If ($CurrentTime == $startTime) Then
            $timer = timerinit()
            do

               //execute function
                Sleep(1000)

            until timerdiff($timer) >= $duration*1000
            ExitLoop

        Else
            $CurrentTime = _NowTime(4)

        EndIf
    WEnd
Edited by DeDee

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