• 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
Rép: Simple newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rép: Simple newbie question


  • Subject: Rép: Simple newbie question
  • From: KOENIG Yvan <email@hidden>
  • Date: Tue, 13 May 2008 21:16:27 +0200

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
  • Prev by Date: Re: Re1: Mail scripting : How to select… continuation...
  • Next by Date: Re: is iPhoto scriptable?
  • Previous by thread: Rép: Wait Until Process Completion
  • Next by thread: Show/Hide extension
  • Index(es):
    • Date
    • Thread