possible to check if an application is running with AppleScript?

I want to check with AppleScript if iCal is already running on the machine. Is there any way to do this?



A better form to do this would be to use a flag instead of crunching the statements. Something like this:

tell application “System Events”
set iCal_exists to (exists process “iCal”)
end tell
if iCal_exists then
beep 2
end if

The reason why you want to do this is that if you send an event within the “System Events” tell block then it will be sent to that app. A common event would be ‘quit’. If sent within the tell block, System Events would quit. New scripters would not know why this is happening, so it is better to put it in this form.

Just my point of view.


Spoken like a man who has (as I have) quit System Events once too often. /ab

Yeah, it’s alomost funny how that keeps happening! :slight_smile:

here’s one I developed for selectable (variable) application check

tell application "System Events"
					set AppleScript's text item delimiters to {","}
					set theprocess to name of every process as list
				end tell
				if theprocess does not contain "Ical" then -- "Ical" can be replaced w/ variable string
					tell application "Ical" to activate
				end if