Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Enthusiast Zone > Classic Macs and Mac OS > Applescript --> Sleep

Applescript --> Sleep
Thread Tools
mlknowle
Forum Regular
Join Date: Nov 2000
Location: RI, USA
Status: Offline
Reply With Quote
Mar 24, 2001, 01:38 PM
 
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
Forum Regular
Join Date: Feb 2001
Status: Offline
Reply With Quote
Mar 24, 2001, 02: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
try
set A to A as number
on error
error "This is not a number."
end try
delay (A * 60)
tell application "Finder"
sleep
end tell

(12)
     
mlknowle  (op)
Forum Regular
Join Date: Nov 2000
Location: RI, USA
Status: Offline
Reply With Quote
Mar 24, 2001, 03:21 PM
 
For some reason, when ever I run this, it brings up an error: "The variable sleep is not defined"

thanks
     
Storyboy
Dedicated MacNNer
Join Date: Jun 2000
Status: Offline
Reply With Quote
Mar 24, 2001, 11: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
Indeed, I tremble for my country when I reflect that God is just.

iMac Core2Duo 2.16GHz/3G RAM/250G HD OSX 10.6.6
Various Peripherals
     
AppleScript
Forum Regular
Join Date: Feb 2001
Status: Offline
Reply With Quote
Mar 25, 2001, 12:55 AM
 
The sleep command needs to be inside the tell block to work. If it still doesn't work, replace sleep with �event fndrslep�.

(13)
     
mlknowle  (op)
Forum Regular
Join Date: Nov 2000
Location: RI, USA
Status: Offline
Reply With Quote
Mar 25, 2001, 11: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
Forum Regular
Join Date: Jan 2001
Location: Bruges, Belgium
Status: Offline
Reply With Quote
Mar 27, 2001, 12:32 PM
 
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.

-c
-c
     
caifara
Forum Regular
Join Date: Jan 2001
Location: Bruges, Belgium
Status: Offline
Reply With Quote
Mar 29, 2001, 04: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
-caifara
-c
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 11:57 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,