2013-07-22 31 views
0

我試圖選擇OSX中的某個終端選項卡並向其發送擊鍵。但是OSX 10.8.4中的終端似乎沒有爲標籤的自定義標題存儲「終端」,即使您爲檢查員設置了自定義標題。有任何想法嗎?這是我想用它來選擇合適的標籤代碼:無法檢索OSX終端選項卡的自定義標題

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 custom title of tab j of window i contains "blah" 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 

回答

0

我工作的一箇舊版本的OSX的,所以我不能複製你的問題(你的代碼正常工作對我來說) ,但也許嘗試:

if ((custom title of (current settings of (tab j of (window i)))) as string) contains "blah" then 
+0

謝謝,但似乎沒有工作。 – cayblood

+0

@CarlYoungblood啊,在這種情況下,我會建議查看AppleScript庫並查看是否可以找到正確的語法。 – scohe001

0

確保你這樣設置的標籤名稱:

tell "application" "Terminal" 
# ... 
    set the_tab to tab 1 of the front window -- replace with your tab selector 
    tell settings set "Basic" 
     set custom title of the_tab to "My Tab Name" 
    end tell 
# ... 
end tell 

你應該能夠得到檢索標籤名稱:

tell "application" "Terminal" 
    set the_name to custom title of the_tab as string 
end tell 

適用於OSX的我10.8.4