Jump to content

App sleeps until a specific time....


 Share

Recommended Posts

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,

Freedom1

If 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

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 script

Is 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

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...