Joec49 Posted June 11, 2008 Posted June 11, 2008 This would be great. Otherwise I need to check the clock in a loop until the time arrives. Minute resolution would be fine. In pseudocode _WaitUntil(hhmmss,myprogram) ;hhmmss is a number like 113400 (11:34am) When the time arrives, AutoIt would then run 'myprogram' - is there such a feature? I have used a feature like that in Java but would love to have it here also. Joe joec_49@hotmail.com
monoceres Posted June 11, 2008 Posted June 11, 2008 This would be great. Otherwise I need to check the clock in a loop until the time arrives. Minute resolution would be fine. In pseudocode _WaitUntil(hhmmss,myprogram) ;hhmmss is a number like 113400 (11:34am) When the time arrives, AutoIt would then run 'myprogram' - is there such a feature? I have used a feature like that in Java but would love to have it here also. Joe joec_49@hotmail.com What's wrong with checking the clock in a loop? Do Sleep(100) Until @Hour=11 And @Min=34 Broken link? PM me and I'll send you the file!
Joec49 Posted June 11, 2008 Author Posted June 11, 2008 >What's wrong with checking the clock in a loop? >Do > Sleep(100) >Until @Hour=11 And @Min=34 That would work but I want to keep the cpu idle until the time arrives. I do a variation of what you suggest and the cpu shows autoit taking 97% of the cpu. If I can truly just wait until hh:mm, then autoit would sit idle until that time, which is what I want. As a side comment, java has it and it works fine. But I prefer AutoIt Joe
monoceres Posted June 11, 2008 Posted June 11, 2008 >What's wrong with checking the clock in a loop? >Do > Sleep(100) >Until @Hour=11 And @Min=34 That would work but I want to keep the cpu idle until the time arrives. I do a variation of what you suggest and the cpu shows autoit taking 97% of the cpu. If I can truly just wait until hh:mm, then autoit would sit idle until that time, which is what I want. As a side comment, java has it and it works fine. But I prefer AutoIt Joe If that code uses 97% of your CPU, then you sir have the worlds slowest pc... no way autoit uses that much cpu time when just checking a conditional statement every 100 ms. Anyway here's one that doesn't loop: #include <date.au3> $timetorun="2008-06-12 19:53:00" $seconds=_DateDiff("s",_Now(),$timetorun) Sleep($seconds*1000) ;.... Run or do something Broken link? PM me and I'll send you the file!
Joec49 Posted June 11, 2008 Author Posted June 11, 2008 I added a counter and the autoit gui loops some 320,000 times before a new minute pops up so I am checking the current time some 320,000 times to see when the minute changes. While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then CLOSEClicked() EventCheck() ;'this checks for new minutes on each loop iteration Wend It would be far better to not loop at all and simply have a feature that works like this (pseudocode) waitUntil(hhmmss,myprogram) (or) waitUntil(elapsedtime,myprogram) in both cases, the waitUntil function would be idle until the time arrives or elapses and then fires up myprogram(). Does anyone know of such a feature in Autoit? If not, it would be nice to have such a feature.... Joe
TurionAltec Posted June 11, 2008 Posted June 11, 2008 Does anyone know of such a feature in Autoit? If not, it would be nice to have such a feature....See monoceres's post.
Joec49 Posted June 11, 2008 Author Posted June 11, 2008 I found an answer that works for me: While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then CLOSEClicked() sleep(2000) ;************wait 2 seconds in each loop to keep cpu load low**************** EventCheck() ;this is a new event, just for this program WEnd I inserted a 2 sec delay each loop and then check if time has arrived. It cuts the loops from 320,000 to about 75 or so. The GUI still responds as if no delay....this is not the preferred solution but it works.
monoceres Posted June 11, 2008 Posted June 11, 2008 Look into OnEvent code, then you can sleep your main loop as long as you want... Example: Opt("GUIOnEventMode",1) GUICreate("Sample",300,200) GUISetOnEvent(-3,"close") GUISetState() Do Sleep(30*1000) Until False Func close () Exit EndFunc Broken link? PM me and I'll send you the file!
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