私はそれを働かせました。それはいくつかの部分が必要です:
- 実行中のアプリケーションの名前を取得します。これは、
processes
のSystem Events
またはそれ以外の場合はdo shell script "ps …"
のいずれかで行うことができます。いずれの場合でも、より信頼性の高いものになります。
- その後、はあなた Mac上のアプリ 1から用語を使用して、あなたは
- * ...アプリケーション appNameのを伝えることができ、あなたが
- がアプリケーションとしてスクリプトを保存していることを提供すでにコンパイルされています。
ここにいくつかのコードがあります。私が取り組んでいるスクリプトは、まだシステムイベントに頼っていないので、システム環境設定への旅行の苦労を新しいユーザーに抱かせるために、私は/ bin/psを使用することを選択しました...
set appName to runningAppWithBaseName("Foo")
using terms from application "Foo Deluxe" -- an app on your Mac
tell application appName
(* whatever code you want here *)
end tell
end using terms from
on runningAppWithBaseName(baseName)
set command to "/bin/ps -eo args | grep " & baseName & " | grep -v grep"
(* The "grep -v grep" is to exclude the grep process itself from the results. *)
try
set fullPathOfRunningApp to do shell script command
end try
(* Here, given the fullPathOfRunningApp and your list of candidate app names, *)
(* insert code to determine the name of the running app. *)
return nameOfRunningApp
end runningAppWithBaseName