Re: Try to quit
Re: Try to quit
- Subject: Re: Try to quit
- From: "Christopher C. Stone" <email@hidden>
- Date: Mon, 11 Dec 2000 10:10:37 -0600
At 13:44 +0100 12/11/00, email@hidden wrote:
>
tell application "Finder"
>
activate
>
try
>
quit application "Fetch 3.0.3"
>
end try
>
end tell
>
>
How has the script to be modified so that it simply quits a running
>
application and does not launch the app when it is not running.
___________________________________________________________________________
Hello Michael,
This is a bit unusual looking but should work on MacOS back to about 7.6.
The tell-by-variable technique technique is useful when you don't know for certain what the name of the app might have been changed to, but you know it's creator code.
on quitApp(appPSN)
with timeout of 1 second
try
tell appPSN to quit
end try
end timeout
end quitApp
tell application "Finder"
try
set appPSN to (process 1 whose creator type is "FTCh")
if appPSN is not equal to {} then
set appPSN to (item 1 of appPSN) as +class psn ;
my quitApp(appPSN)
else
beep
tell me to display dialog "Fetch isn't running." with icon 2
end if
end try
end tell
("class psn " should be enclosed by chevrons similar to <<class psn >>
but using option-\ & option-shift-\)
MacOS 9 will let you tell-by-variable without resorting to using the coercion.
set f to "Fetch 3.0.3"
tell application f to quit
One pitfall with Fetch is that when a New Connection window is open it cannot quit, nor have I found a means of closing said window via script.
Best Regards,
Chris