Application Status

What is the easiest way to tell if an application is open? Or how to get a list of currently open applications, so I know which to close.

And… is there anyway to get around the Script Editor from asking where program is when I use the “Tell Application «application name»” line?


The Finder’s ‘processes’ should tell you what you want to know. The following gives the names of active applications and extensions:

  tell application "Finder"
    set theProcesses to name of every process
  end tell

If you just want the names of open applications:

  tell application "Finder"
    set theApps to name of every process whose file type is "APPL" -- must be upper case

When closing an application, it’s best not to use the word ‘quit’ inside a Finder tell block as the Finder itself will then usually quit. You may be looking for a piece of code like this:

  tell application "Finder"
    process "My App" exists
  end tell
  if the result is true then tell application "My App" to quit

Here’s a reliable way of quitting all open applications except for the one actually running the script:

  set myPath to path to me
    tell application "Finder"
      set myName to myPath's name
      set appNames to (name of every process whose ¬
        file type is "APPL" and name is not myName) as list
    end tell
    repeat with thisName in reverse of appNames
      tell application thisName to quit
    end repeat
  on error
  end try

I use ‘reverse’ above to close the apps in the opposite order to that in which they were opened. Hopefully, this reduces memory fragmentation - but I’m not absolutely sure…