Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Trigger Applescript on application exit?

Is it possible to launch an Applescript upon closing out of a separate application?

I play World of Warcraft and it erases my Expose settings each time. (See discussion about this problem here: http://discussions.apple.com/message.jspa?messageID=5709379#5709379) Fortunately, someone has written a script that automatically returns the settings back to their defaults. The annoying thing is I have to run it each time manually and sometimes I forget.

Any way to get a script to watch World of Warcraft.app and trigger when the app closes?

Thanks.

MacBook Pro 15", Mac OS X (10.5.1), 2 GB RAM

Posted on Jan 27, 2008 6:53 PM

Reply
4 replies

Jan 27, 2008 7:38 PM in response to Philpott

There isn't any trigger when an application quits, but you can run a stay-open script that checks to see if a process is running or not. For example, the following script will run the application and then check every five minutes to see if it is still running (save is as a stay-open application):

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFDDFF;
overflow: auto;"
title="this text can be pasted into the Script Editor">
property LookTime : 5 * 60 -- interval to check process

on run
tell application "World Of Warcraft" to activate -- start it up
delay LookTime -- initial delay before idle
end run

on idle
tell application "System Events"
if (exists application process "World of Warcraft") then return LookTime -- check again later
end tell
-- application is not running, so run script here
quit
end idle
</pre>

Apr 25, 2008 7:57 AM in response to Philpott

Hi everyone,
I've tried this program and so far it hasn't worked. It doesn't seem to do anything as far as I can tell. I have a real need for an applescript to run automatically when MSWord quits. I tried setting it for another application too just as a test, and it didn't work either. The applescript runs by itself just fine. Any ideas or is there another program (or script) that can do this? Thanks,
Sean

Trigger Applescript on application exit?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.