DeDee Posted October 27, 2014 Posted October 27, 2014 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?
Moderators JLogan3o13 Posted October 27, 2014 Moderators Posted October 27, 2014 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 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
DeDee Posted October 27, 2014 Author Posted October 27, 2014 (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? expandcollapse popup#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 October 27, 2014 by DeDee
DeDee Posted October 28, 2014 Author Posted October 28, 2014 (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 October 28, 2014 by DeDee
junkew Posted October 28, 2014 Posted October 28, 2014 did you try the help example? https://www.autoitscript.com/autoit3/docs/functions/AdlibRegister.htm FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now