Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm trying to make an alarm clock for myself with AppleScript after my old (physical) one crapped out. I've got a script that'll schedule a pmset wakeup at the requisite time. There's just the matter of making the script actually make noise at that moment.

To that regard, does the actionscript delay command count time the computer was asleep? It'd be nice to say

delay (# of seconds between now and when I have to wake up the next morning)

, but if delay doesn't count down when the computer's off (or, rather, retroactively decrement the countdown upon wake), then I'll need some other way of doing things.

Does anyone know about this behavior, and any workarounds if the answer is 'it doesn't count time asleep'?

share|improve this question
    
This should be fairly easy to test with a five minute delay and you sleeping the Mac for three minutes in the middle of the countdown.... –  bmike Jul 27 '12 at 5:45
    
I have indeed tested it. The answer is: Nope, delay is suspended during sleep. –  SoItBegins Jul 27 '12 at 6:35
    
Feel free to answer your question or edit the best answer to include this ;-) –  bmike Jul 27 '12 at 14:26

1 Answer 1

I doubt that applescript keeps delay during sleep. I guess what you can do is when you want to start the delay, get the current time, then set a repeated delay, something like as following. I'll write this in psuedo-code since I'm not too familiar with applescript anymore

startDelayDate = current date
shouldRepeat = yes
repeat while shouldRepeat is equal to yes
    delay(1)
    if (((current date) - startDelayDate)>=yourDelayTime) //You'll have to implement your own date checking method
        //Do your stuff
end repeat
share|improve this answer
1  
Okay... thanks. I'll try that, and also script-set iCal alarms. –  SoItBegins Jul 27 '12 at 5:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.