MacOS – How to make two applications activate from an AppleScript app


So I am playing around with AppleScript and am quite new to it.

How do I make the script quit both apps if:

  • app1 and app2 are running
  • or if app1 or app2 is running
  • and run them if they are not running

My script:

if application "app" is running or "app2" is running then
        tell application "app1" to quit
        tell application "app2" to quit
        tell application "app1" to activate
        tell application "app2" to activate
end if

Best Answer

I think this may be what you're looking for.

set app1 to "TextEdit" -- Change as needed
set app2 to "Mail" -- Change as needed

if (application app1 is running or application app2 is running) or ¬
    (application app1 is running and application app2 is running) then
    tell application app1 to quit
    tell application app2 to quit
    tell application app1 to activate
    tell application app2 to activate
end if