• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
(no subject)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(no subject)


  • Subject: (no subject)
  • From: email@hidden
  • Date: Tue, 03 May 2005 22:03:06 +1000

Hey, this is Rohan Vicars. I'm reasonably new to AppleScript but i've been developing
a script so that i can tell my computer to shut down after a certain time. My problem is that
i use the delay command and my script has an "AppleEvent Timed out" error if i set the
script to more than a few minutes. How do i stop this. My second question is how to make
my script shut down even if an application doesn't want to quit (Say, Microsoft word has
an open file that hasn't been saved) What do i do?

Here is a copy of the script.


tell me
	activate
end tell
display dialog ¬
	"Are you sure you want to shut down?" buttons {"Yes", "Cancel", "Wait ... Minutes"} ¬
	default button 2

if the button returned of the result is "Yes" then
	tell application "Finder"
		shut down
	end tell

else if the button returned of the result is "Cancel" then
	tell me
		quit
	end tell

else if the button returned of the result is "Wait ... Minutes" then
	repeat
		tell me
			activate
		end tell
		display dialog ¬
			"How many minutes till shutdown?" default answer "5" buttons {"Ok", "Cancel"} ¬
			default button 2

		set the Quantity to the text returned of the result

		if the Quantity contains "." then
			beep
			display dialog "The Number cannot contain a period (.) or any non numerical characters." buttons
{"Cancel", "OK"} default button 2
		else if the Quantity contains " " then
			beep
			display dialog "The Number cannot contain a space or any non numerical characters." buttons
{"Cancel", "OK"} default button 2
		else if the Quantity contains "a" or the Quantity contains "b" or the Quantity contains "c" or the
Quantity contains "d" or the Quantity contains "e" or the Quantity contains "f" or the Quantity contains "g" or
the Quantity contains "h" or the Quantity contains "i" or the Quantity contains "j" or the Quantity contains "k" or
the Quantity contains "l" or the Quantity contains "m" or the Quantity contains "n" or the Quantity contains "p"
or the Quantity contains "q" or the Quantity contains "r" or the Quantity contains "s" or the Quantity contains
"t" or the Quantity contains "u" or the Quantity contains "v" or the Quantity contains "w" or the Quantity
contains "x" or the Quantity contains "y" or the Quantity contains "z" or the Quantity contains "o" then
			beep
			display dialog "The number cannot contain any non numerical characters." buttons {"Cancel", "OK"}
default button 2
		else if the Quantity is less than 1 then
			beep
			display dialog "The number must be a numerical character greater than one" buttons {"Cancel",
"OK"} default button 2

		else
			display dialog "Are you sure you want this computer to shut down" & return & "in " & the Quantity &
" minutes (" & the (Quantity * 60) & " seconds)?" buttons {"Shut Down in " & the Quantity & " Minutes",
"Cancel"} ¬
				default button 1
			if the button returned of the result is not "Cancel" then
				tell application "Finder"
					activate
					delay (10  + (Quantity * 60) - 30)
				end tell
				tell me
					activate
				end tell
				display dialog ¬
					"This Computer Is Scheduled to Shut Down In 10 Seconds" buttons ("Cancel") ¬
					default button 1 ¬
					giving up after 10

				if the button returned of the result is not "Cancel" then
					tell application "Finder"
						delay 5
						shut down
						tell me
							quit
						end tell
						delay 5
					end tell
				end if
			end if
			exit repeat
		end if
	end repeat
end if

Cheers,
Rohan
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Shut down now
      • From: Gnarlodious <email@hidden>
  • Prev by Date: New Tiger dictionary format example posted
  • Next by Date: Re: Help with droplet
  • Previous by thread: Re: New Tiger dictionary format example posted
  • Next by thread: Shut down now
  • Index(es):
    • Date
    • Thread