我正在尝试在OSX中选择某个终端选项卡并向其发送击键。但是,OSX 10.8.4中的终端似乎不会为选项卡的自定义标题存储任何“终端”,即使您使用检查器设置了自定义标题。有任何想法吗?以下是我想用来选择正确选项卡的代码:
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 :(得分:0)
我正在使用旧版本的OSX,所以我无法复制您的问题(您的代码对我来说很好),但也许可以尝试:
if ((custom title of (current settings of (tab j of (window i)))) as string) contains "blah" then
答案 1 :(得分: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上为我工作