Script to watch for activation of an application

Hello all!
I am somewhat new to applecripting, but I was wondering if there was a way to create a script to watch or check if a certain application has been launched.

I want to create an application add-on so to speak that will launch if another specified application is launched.

Any help would be greatly appreciated.


Hi whiteink,

to check if a certain application is running you can use sth like this:

tell application "Finder"
	if (name of every application process) contains "Safari" then
		display dialog "Safari is running"
	end if
end tell

you could put this in a stay open on idle script … but that’s not a very nice solution.

Or maybe you can use this Addition:


Hi Dominik,

I don’t see what’s not very nice about the idle handler. It hardly takes up cpu usage (depending on what it does), and can be made to run in the background just like any background process.

global is_running

on run
set is_running to false
end run

on idle
tell application “System Events”
if exists process “iCal” then
set is_running to true
set is_running to false
end if
end tell
if is_running then
beep 1
– do whatever
end if
return 2 – checks every 2 seconds
end idle


Hi kel,

I haven’t tried the addition I mentioned, but I think they might listen to notifications which would be a more elegant solution. But you are right - there is nothing wrong with an on idle handler.


Hi Dominik,

Yes, that would be better. There wouldn’t be the short delay.


Wow Guys! Props to you. :wink:

The idle handler did the trick. It works very well. Never used that before. Thanks so much for the help.