1

tell application currentWindowApplescriptで変数を渡すにはどうすればよい ですか?

私はこのコードを持っています:

tell application "System Events"
    set currentWindow to get name of processes whose frontmost is true
end tell

-- get bundle identifier of (info for (path to application currentWindow)) -- KO
-- tell application id currentWindow -- KO
-- tell application "Finder" -- ok
tell application currentWindow -- KO!
    activate
end tell

currentWindowもちろん、名前を知らずに開きたいです。

ありがとう。

4

2 に答える 2

1

adayzdone の方が優れた方法ですが、コードの主な問題は、currentWindow が名前のリスト {"フロント アプリケーション名"} であることです。「プロセスの名前」を複数形で求めて、結果をリストに戻します。リストなので、リストの項目にアクセスする必要があります。したがって、これはおそらくうまくいくでしょう。adayzdone が「最初のアプリケーション プロセス」を要求したため、結果が 1 つしか得られず、リストではないことがわかります。

tell application "System Events"
    set currentWindow to get name of processes whose frontmost is true
end tell

tell application (item 1 of currentWindow)
    activate
end tell
于 2013-06-25T05:14:48.260 に答える