Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

talguy

macrumors member
Original poster
Jun 17, 2009
30
0
How can I make it so that snow leopard executes and applescript when a certain application quits
 
To the best of my knowledge there is no way to do it. You could write your own background app that monitors for app startup and stop and the calls an AppleScript when an app dies. But if your code is not already running I don't see how you would receive the notification of app shutdown.
 
ok thanks for the information. I just thought that the OS had the option of executing a script on application quit.
 
Unless the specific application provides some mechanism to do that I don't think so (and a Google search gives no indication of an OS mechanism to do it that I was not aware of).
 
You could create a script that launches the app and then tells your monitor script to start waiting for the app to quit, then when it does, the monitor script can call your quit script.

If you give the first script the same icon as your app, you can put that in the dock and the process begins transparently.

mt
 
here is some sample code for this

Code:
on idle
	
	
	tell application "System Events" to ¬
		set exists_ to exists process "PandoraBoy"
	
	if exists_ is false then
		tell application "Airfoil"
			quit
		end tell
		quit me
	end if
	
	
	set timercount to timercount + 1
	return 10 -- checks every 10 seconds to see if app has been quit
	
end idle

to make it not open in the dock

save the script as an application bundle. (Make sure to deselect "Startup Screen" then right click -> show package contents -> Info.plist add item "Appliction is background only" and check selected.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.