2013-07-25 1 views

Répondre

1

Oui, vous pouvez.

Sur mon Blog thecocoaquest J'ai deux messages qui couvrent cela. Le premier article vous montre une méthode pour ce faire avec un applescript et en utilisant un agent de lancement.

Applescript – Quit or Launch Application if another is or is not running

Voici un des exemples:

Si j'ai une application en cours d'exécution de la deuxième application démarre et sera toujours en cours d'exécution tandis que la première application est en cours d'exécution.

Ou quand je quitte la première application de la deuxième application sera également quit

#!/usr/bin/osascript 
#Copyright Mark Hunte 2012 
#http://www.markosx.com/thecocoaquest/kill-one-application-if-another-is-not-running-applescript 
set appMustBeRunning to "xcode" 
set appToKill to "Snippets" 
tell application "System Events" 
    set appMustBeRunningID to (unix id of processes whose name is appMustBeRunning) 
    set appToKillID to (unix id of processes whose name is appToKill) 
end tell 
if appMustBeRunningID is {} then 
    try 
     tell application "Snippets" to quit 
    end try 

else if appToKillID is {} then 
    tell application "Snippets" to launch 
end if 

Le deuxième poste est une révision montrant comment ajouter plus d'une application maître-esclave &

Applescript – Quit or Launch Application script.. (Revised)

A également un script pour si vous voulez juste exécuter Applescript en tant qu'application.

+0

Génial c'est exactement ce que je cherchais! Je ne sais pas grand-chose sur l'applescript, mais c'est quelque chose que je veux apprendre et je pense que ce serait quelque chose que je voudrais commencer. Très appréciée. –

+0

Bonjour John E, Votre accueil – markhunte

Questions connexes