Re: Simple newbie question
Re: Simple newbie question
- Subject: Re: Simple newbie question
- From: KOENIG Yvan <email@hidden>
- Date: Tue, 13 May 2008 16:25:58 +0200
Le 13 mai 2008 à 15:29, Michelle Steiner a écrit :
On May 12, 2008, at 11:58 PM, ba95 wrote:
-- define app1 and app2
tell application "Finder"
try
if "App1" is not in (get every process) then
open application app1
open application App2
else
quit application app1
quit application App2
end if
end try
end tell
--
Thanks a lot Michelle.
Unfortunately the script does not work here.
Launching time: only "App1" is opened
Quiting time: nothing happens.
I just noticed an error in the script; there shouldn't be quotes
around "app1" in the "if" line.
To get rid of the problem I wrote these scripts:
tell application "Finder"
set dispo to (get title of every process)
if "App1" is not in dispo then
(* App1 is not open so App2 isn't too *)
try
openapplication "App1"
open application "App2"
end try
(* here we may have:
App1 and App2 open
App1 open but not App2
none open *)
else
(* App1 is open but we don't know if App2 is open *)
try
if "App2" is in dispo then quit application "App2"
end try
try
quit application "App1"
end try
end tell
But, some times ago, ba95 asked me upon an app
which generates an error even when it opens flawlessly
(Stickies is such an app, which generates an error -1708).
So I added this version
set fausseErreur to -1708 (* put here the true App1's error code *)
tell application "Finder"
set dispo to (get title of every process)
set flag to true
if "App1" is not in dispo then
(* App1 is not open so App2 isn't too *)
try
openapplication "App1"
on error errMsg number errNum
if errNum is not fausseErreur then set flag to false
end try
if flag is true then
try
open application "App2"
end try
end if
(* here we may have:
App1 and App2 open
App1 open but not App2
none open *)
else
(* App1 is open but we don't know if App2 is open *)
try
if "App2" is in dispo then quit application "App2"
end try
try
quit application "App1"
end try
end tell
As I don't know the apps, I don't know if the pair try/end try are
useful for the quit instructions.
Yvan KOENIG (from FRANCE mardi 13 mai 2008 16:21:31)
_______________________________________________
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