• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Simple newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple newbie question


  • Subject: Re: Simple newbie question
  • From: Axel Luttgens <email@hidden>
  • Date: Tue, 13 May 2008 16:55:06 +0200

Le 13 mai 08 à 11:13, ba95 a écrit :

I must apologie if I have not made myself clear enough.

My initial mail started with:
----
Here comes a script
It launches 2 linked applications if they are not opened, and quits them if they are (toggle).
--


I just want 2 linked applications to launch together (if they are not opened) or quit together (if they are opened) with an AS.


Please find hereafter my understanding of your question.

-- Let's assume identical process and application names.
-- Otherwise, one should for example distinguish App1ApplName and App1ProcName.
property App1 : "TextEdit"
property App2 : "Console"


tell application "System Events"
	set App1IsRunning to application process App1 exists
	set App2IsRunning to application process App2 exists
end tell

-- If App1 can't be launched (App2 can't be quit), don't launch App2 (quit App1).
try
-- Since App1 and App2 are linked, let's make sure both are quit
-- if at least one of those apps is running.
if App1IsRunning or App2IsRunning then
if App2IsRunning then tell application App2 to quit
if App1IsRunning then tell application App1 to quit
--Neither App1 nor App2 is running, so let's try to launch both.
else
-- Depending of the app, "launch" could be a better choice than "run".
tell application App1 to run
tell application App2 to run
end if
end try


HTH,
Axel

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >RE: Simple newbie question (From: ba95 <email@hidden>)

  • Prev by Date: Rép: Wait Until Process Completion
  • Next by Date: Re: Circle-Slash
  • Previous by thread: RE: Simple newbie question
  • Next by thread: Simple newbie question
  • Index(es):
    • Date
    • Thread