Freedom1 Posted October 21, 2008 Share Posted October 21, 2008 Hello,I want to write a small app that starts up when the PC is started and waits till a specific time to continue with execution of code. Lets say the PC is turned on at 8am and my app starts and runs in the background. It waits until 4pm and then starts to perform it functions.I know I could use XP scheduler but I'd like to have it all in AutoIt.I dont want to burn up bunches of CPU cycles while waiting. How do I code it?Thanks,Freedom1If you want to see my entire task look at it here: http://www.autoitscript.com/forum/index.ph...c=82512&hl= Link to comment Share on other sites More sharing options...
oMBRa Posted October 21, 2008 Share Posted October 21, 2008 something like: While @HOUR < 16 Sleep(100) Wend Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 21, 2008 Share Posted October 21, 2008 You could probably even change that Sleep to something large like 5 minutes. Link to comment Share on other sites More sharing options...
Freedom1 Posted October 22, 2008 Author Share Posted October 22, 2008 You could probably even change that Sleep to something large like 5 minutes.Thank you oMBra and Richard for your suggestion. I should have tried it first. For some reason I thought "Sleep" would use a lot of cycles like a tight loop. After viewing the performance panel of the task manager I see that it uses very few cycles. AutoIt is a winner. As for the code, I'm thinking:; Calculate time in milliseconds between now and wakeup time; sleep(Calculated Milliseconds); Continue onward with rest of scriptIs there any problem with sleeping a large calculated-millisecond value? Say the wakeup time is 4pm and the current time is 6pm the calculated milliseconds would be 22 * 3,600,000 = Sleep(79,200,000)Thanks alot,Freedom1 Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 22, 2008 Share Posted October 22, 2008 That should be fine as long as you don't have the commas in it. If you wanted to be absolutely sure you could do something like $time = _DateDiff("s",_NowCalc(),*end time*);return in seconds the difference Sleep(Number($time * 1000));calculate ms difference and sleep. ;rest of code Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 22, 2008 Share Posted October 22, 2008 Using sleep will drastically reduce CPU cycles because sleep causes the thread to cease doing anything until the time has expired. Link to comment Share on other sites More sharing options...
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