3

これはアプリケーション固有の問題です。内容に応じて、Terminal.app のタブを見つけて選択しようとしています。これが私がやっていることです:

tell application "Terminal"
    set foundTabs to (every tab of every window) whose contents contains "selectme"
    repeat with possibleTab in foundTabs
        try
            set selected of possibleTab to true
        end try
    end repeat
end tell

これは期待どおりに動作しておらず、非常に簡単です。より少ないコードでこれを行う方法を誰かが提案できるかどうか疑問に思います (たとえば、ループは実際には必要ないはずですが、applescript はとらえどころのない言語です)。

ありがとう

4

1 に答える 1

2

つまり、次の Applescript はあなたが望むことを行いますが、「selectme」文字列が非常にユニークでない限り、多くのタブで見つけることができます。とにかく、ここに行きます:

tell application "Terminal"
set allWindows to number of windows

repeat with i from 1 to allWindows
    set allTabs to number of tabs of window i
    repeat with j from 1 to allTabs
        if contents of tab j of window i contains "selectme" then
            set frontmost of window i to true
            set selected of tab j of window i to true
        end if
    end repeat
end repeat
end tell
于 2011-02-19T09:00:19.850 に答える