Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the '10.6: Sleep computer via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Sleep computer via AppleScript
Authored by: n6ac on Apr 27, '10 10:19:34AM

For what it's worth, here's a sleep script with timer -

global timer
display dialog "You may select the delay before sleep ... " & " If you do nothing sleep starts in 10 seconds" buttons {"Cancel", "Sleep Now", "Select Delay"} cancel button 1 default button 2 with icon 2 with title "Sleep in 321 Seconds" giving up after 10
if button returned of result is "Sleep Now" then
say "Iam going to sleep rite now. Buy"
else if button returned of result is "Select Delay" then
else if gave up of result is true then
end if

on sleepnow()
say "pretend i am asleep" --remove this line if you REALLY want to sleep
--tell application "Finder" to sleep ---uncomment this to REALLY sleep
end sleepnow

on SelectDelay()
display dialog "Enter the number of seconds before sleep:" default answer "5" with title "Sleep in 321 Seconds"
set timer to the text returned of the result as integer
repeat until timer is 0
display dialog "Time until sleep is: " & timer & " seconds" buttons {"Cancel"} default button 1 with title "Sleep in 321 Seconds" giving up after 1
set timer to timer - 1
end repeat
end SelectDelay

[ Reply to This | # ]