MacNN Forums (
-   Classic Macs and Mac OS (
-   -   Applescript --> Sleep (

mlknowle Mar 24, 2001 12:38 PM
Applescript --> Sleep
Can anyone help me with this? Its a pretty simple question, but I've looked all over and can't find an answer. I'm trying to write an applescript that will wait x minutes, and then put the computer to sleep. Any ideas? thanks
AppleScript Mar 24, 2001 01:20 PM
set A to display dialog "How many minutes do you want to wait before sleep?" with icon note buttons {"Cancel", "OK"} default button "OK" default answer ""
set A to the text returned of A
set A to A as number
on error
error "This is not a number."
end try
delay (A * 60)
tell application "Finder"
end tell

mlknowle Mar 24, 2001 02:21 PM
For some reason, when ever I run this, it brings up an error: "The variable sleep is not defined"

Storyboy Mar 24, 2001 10:10 PM
Is this a workaround for the OS 9.1 Insomnia that seems to be plaguing so many of us? I'm being driven insane.

"The only consistant people I know are dead."

iMac DVSE 400/128/13
OS 9.0.4
AppleScript Mar 24, 2001 11:55 PM
The sleep command needs to be inside the tell block to work. If it still doesn't work, replace sleep with «event fndrslep».

mlknowle Mar 25, 2001 10:35 AM
It keeps bringing up an error that says:

"Finder got an error: Can't continue <<event fndrslep>>"

I have tried this both in X and in 9, but to no avail. Any other ideas? Thanks again.
caifara Mar 27, 2001 11:32 AM
got something for it, but now i'm at school working on pc
gonna write it down from my computer (the program has a stop process button too). I use it when i go to bed, but don't want to stop music yett.

caifara Mar 29, 2001 03:07 AM
hi, I found it, here it comes:

--how many minutes
set antw to display dialog ("time in minutes till activation sleep mode") default answer ("10")

set tijd to (text returned of antw) as integer

--stop proces possibility
set a to display dialog {"proces started"} buttons {"stop"} giving up after (tijd * 60)

if gave up of a is true then
tell application "finder" to sleep

end if
--made by caifara

/the end
it works for me, hope it works for you too, let me know something
All times are GMT -4. The time now is 12:42 PM.

Copyright © 2005-2007 MacNN. All rights reserved.
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.

Content Relevant URLs by vBSEO 3.3.2