0

私はスクリプトを学習しているだけで、1 つのウィンドウで 13 個のタブを開くソリューションが必要です。これをウィンドウごとに実行し、タブごとに値を増やして「telnet localhost 2001」...「telnet localhost 2013」とし、各タブに名前を付けます。 R1..R1、次に SW1..SW4、次に BB1..BB3。

これは、最初と3番目の部分にはできるが、2番目にはできない方法です。

tell application "Terminal"  
activate  
tell application "System Events" to keystroke "n" using {command down}  
tell application "System Events" to keystroke "t" using {command down}  
set custom title of tab 1 of window 1 to "R1"  
tell application "System Events" to keystroke "t" using {command down}  
set custom title of tab 2 of window 1 to "R2"  
tell application "System Events" to keystroke "t" using {command down}  
set custom title of tab 3 of window 1 to "R3"  
tell application "System Events" to keystroke "t" using {command down}  
set custom title of tab 4 of window 1 to "R4"  
tell application "System Events" to keystroke "t" using {command down}  
set custom title of tab 5 of window 1 to "R5"  
tell application "System Events" to keystroke "t" using {command down}  
set custom title of tab 6 of window 1 to "R6"  
tell application "System Events" to keystroke "t" using {command down}  
set custom title of tab 7 of window 1 to "SW1"  
tell application "System Events" to keystroke "t" using {command down}  
set custom title of tab 8 of window 1 to "SW2"  
tell application "System Events" to keystroke "t" using {command down}  
set custom title of tab 9 of window 1 to "SW3"  
tell application "System Events" to keystroke "t" using {command down}  
set custom title of tab 10 of window 1 to "SW4"  
tell application "System Events" to keystroke "t" using {command down}  
set custom title of tab 11 of window 1 to "BB1"  
tell application "System Events" to keystroke "t" using {command down}  
set custom title of tab 12 of window 1 to "BB2"  
tell application "System Events" to keystroke "t" using {command down}  
set custom title of tab 13 of window 1 to "BB3"  

end tell

値のサブを実行する必要がありますが、必要に応じて動作させた後、それを処理できます。

誰かが私の問題を解決するのを手伝ってくれますか

do script ("telnet localhost 2001")

現在、各タブを開いたときに失敗しますか?

4

3 に答える 3

0

これを試して...

set shortDelay to 0.2
set tabTitles to {"R1", "R2", "R3", "R4", "R5", "R6", "SW1", "SW2", "SW3", "SW4", "BB1", "BB2", "BB3"}

tell application "Terminal"
    activate
    set frontWindow to window 1
    repeat with i from 1 to 13
        if i is not 1 then
            activate
            tell application "System Events" to keystroke "t" using command down
            delay shortDelay
        end if
        set custom title of tab i of frontWindow to (item i of tabTitles)
        set twoDigits to text -2 thru -1 of ("0" & i)
        do script ("telnet localhost 20" & twoDigits) in frontWindow
    end repeat
end tell
于 2013-10-26T20:53:13.467 に答える