on ApplicationIsRunning(appName) tell application "System Events" to set appNameIsRunning to exists (processes where name is appName) return appNameIsRunning end ApplicationIsRunning
Use it like,
if ApplicationIsRunning("Mail") then display dialog "Don't forget to write mom!" end if
On Mac OS X 10.5, this worked for me even when the application-file’s name was changed. On 10.4 I do not expect that it would still work if someone renamed the application, unless you used the creator type
to locate the process, not the name
.
You might also be interested in how to get the name of the frontmost application, here’s how:
tell application "System Events" to set FrontAppName to name of first process where frontmost is true
if FrontAppName is "DVD Player" then display dialog "Get to work!" end if