0

私にとって最も関連性が高いと考えられる例は、iTunes を閉じたときに last.fm アプリを閉じることができるというものです。私はよく last.fm を閉じるのを忘れてしまい、かなり面倒です。他にも使い道はあると思いますが…

4

1 に答える 1

1

はい、できます。

私のブログ thecocoaquestには、これをカバーする 2 つの投稿があります。

最初の投稿では、applescript と Launch Agent を使用してこれを行う方法を示しています。

Applescript – 別のアプリケーションが実行されているか実行されていない場合は、アプリケーションを終了または起動します

例の 1 つを次に示します。

1 つのアプリを実行している場合、2 番目のアプリが起動し、最初のアプリの実行中に常に実行されます。

または、最初のアプリを終了すると、2 番目のアプリも終了します

#!/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

2 番目の投稿は、複数のマスター & スレーブ アプリケーションを追加する方法を示すリビジョンです。

Applescript – アプリケーション スクリプトの終了または起動.. (改訂版)

Applescript をアプリケーションとして実行したいだけの場合のスクリプトもあります。

于 2013-07-25T21:40:11.483 に答える