Simple newbie question
Simple newbie question
- Subject: Simple newbie question
- From: ba95 <email@hidden>
- Date: Wed, 14 May 2008 08:24:22 +0200
Thanks a lot Yvan. Nice work.
Learning a lot from you (nice french people... ahem ;-)).
Tests made here (MacOS 10.4.11)
-> Launching the script:
- opens Stickies
- does not open TextEdit
-> Relaunching then the script then:
- quits Stickies
- does nothing on TextEdit
-> Launching the script when Stickies and TextEdit are previously
"manually" opened:
- quits both (normal behaviour)
We approach the nirvana. ;-)
Best regards.
Bernard from Paris (not the one in Texas)
Le 14 mai 08 à 07:25, email@hidden a
écrit :
Message: 1
Date: Tue, 13 May 2008 21:16:27 +0200
From: KOENIG Yvan <email@hidden>
Subject: R?p: Simple newbie question
To: asu <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=UTF-8; delsp=yes; format=flowed
Revised version tested with two widely available applications.
set theApp1 to "Stickies"
set theApp2 to "Textedit"
set fausseErreur to -1708
tell application "System Events" to set dispo to (get name of every
process)
if theApp1 is not in dispo then
(* App1 n'est pas ouverte donc App2 ne l'est pas davantage *)
set flag to true
tell application "Finder"
try
open application "Stickies" (* putain d'appli qui n'accepte pas
d'être lancée si le nom est dans une variable *)
on error errMsg number errNum
(* errMsg et errNum sont le message et le numéro d'erreur
générés par l'exécution du script*)
log errNum
if errNum is not fausseErreur then set flag to false
(* fausseErreur étant le numéro de l'erreur
générée par une ouverture réussie *)
end try
end tell
if flag is true then
tell application "Finder"
try
open application theApp2
end try
end tell
end if
(* on peut se retrouver avec:
App1 et App2 ouvertes
App1 ouverte mais pas App2
aucune ouverte *)
else
(* App1 est ouverte mais rien ne garanti que App2 le soit *)
try
if theApp2 is in dispo then tell application theApp2 to quit
end try
try
tell application theApp1 to quit
end try
end if
I was surprised because open application theApp1 with theApp1 set to
"Stickies" doesn't work.
Yvan KOENIG (from FRANCE mardi 13 mai 2008 20:24:55)
_______________________________________________
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