Application Exists

Hi Folks,

how can I check wheter an Application is still running?

Sorry for this stupid question but it looks like that I am sitting on my brain… :slight_smile:

Best regards,

Stefan

here would be one way to do this

tell application "System Events" to if (name of every process) contains "Application Name" then set appStatus to "running"

appStatus is just a variable we made up… so first thing you should do which I forgot to include is set it to “not running” or false or whatever you want…

set appStatus to "not running"
tell application "System Events" to if (name of every process) contains "Application Name" then set appStatus to "running"

Or if you are planning on doing something if it’s not running then you could also do this

tell application "System Events" to if (name of every process) does not contain "Application Name" then
	-- The app is not running so do something here
end if

Hi James,

thanks a lot - now it is clear…

Best Regards,

Stefan

Or

tell application "System Events" to set appStatus to item ((((name of every process) contains "Application Name") as integer) + 1) of {"not running", "running"}

:wink:

LOL I love it Stefan!

I’m missing something here. If you want a binary variable as testament to an app being up and running, what’s the matter with this? Seems to me you don’t have to get all apps that are running and match names; just ask directly. (or have I missed a point?)

tell application "System Events" to set appRunning to exists process "iCal"

I dont think so Adam, I just failed to think of that. I then think Stefan was playing into my love of one-liners :smiley: