Topic : script to open application, and to quit if already open

Discussion in 'Mac Programming' started by seydurin, Nov 18, 2010.

  1. seydurin macrumors member

    Aug 3, 2010
    I already have the script for launching one or more applications, and I could make a new one to quit them, but I was hoping it could be made into the same script. Can this be done?

    here's what I have now:

    tell application "Firefox" to activate

    tell application "BetterTouchTool" to activate
  2. misee macrumors member

    Jul 4, 2010
    set appName to "Terminal"
    tell application "System Events" to set counter to the count of (processes whose name is appName)
    if counter = 0 then
    	tell application appName to activate
    	tell application appName to quit
    end if

Share This Page