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


Click here to return to the 'An AppleScript to generate a timed shutdown [Final Version]' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to generate a timed shutdown [Final Version]
Authored by: cougar718 on Apr 15, '04 02:34:24PM
Here is the final version of this script. It was brought to my attention that there was a critical component of the code missing it is fixed now. Simply compile and Save as an Application and make sure "Stay Open" is checked.

--Created by StevenT 
--Modified by cougar

-- How many seconds before we remove the shutdown notice? 
property pIntTimeout : 3
property pIntTimeAmount : ""
property pDateGoal : ""

on run
	set pDateGoal to ""
	set blnValid to false
	repeat until blnValid
		set recDialog to display dialog "Enter in how many minutes until the computer shuts down?" default answer pIntTimeAmount buttons {"Cancel", "Ok"} default button 2
		try
			set pIntTimeAmount to text returned of recDialog as integer
			if (pIntTimeAmount > 0) then
				set blnValid to true
			else
				error
			end if
		on error
			display dialog "Invalid Number - Numbers must be integers and greater than 0" buttons {"Ok"} default button 1
		end try
	end repeat
	
	set strMinute to " minute"
	if (pIntTimeAmount > 1) then set strMinute to strMinute & "s"
	display dialog "The computer will shutdown in " & pIntTimeAmount & strMinute & "!" buttons {"Ok"} default button 1 giving up after pIntTimeout
	set pDateGoal to (current date) + (pIntTimeAmount * 60)
end run

on idle
	try
		if ((current date) >= pDateGoal) then
			tell application "Finder" to shut down
		end if
	end try
	return 1
end idle

---
Rick alias cougar

[ Reply to This | # ]