in tab 2 of front window returns Terminal got an error: Can’t get tab 2 of window 1. (-1728) since High Sierra update
in tab 2 of front window returns Terminal got an error: Can’t get tab 2 of window 1. (-1728) since High Sierra update
正如标题所说,我有一个苹果脚本可以:
in tab 2 of front window
过去工作正常,但自从 High Sierra 升级后 returns:
Terminal got an error: Can’t get tab 2 of window 1. (-1728)
对应于 errAENoSuchObject
我找不到关于此更改的任何文档 - 这是一个错误吗?有没有新的或更好的方法来做到这一点?
对象层次结构略有变化。每个选项卡在 AppleScript 中被引用为 tab 1 属于唯一的父 window 对象。
因此,以前,如果在一个 window 中打开三个选项卡,我们可以将它们称为 tab 1、tab 2 ,以及 选项卡 3,共 window 1。现在,我们有 tab 1 of window 1, tab 1 of window 2,以及 选项卡 1 of window 3.
我发现定位特定选项卡的最方便可靠的方法是识别包含 选项卡的 window 对象 具有特定 tty 属性 值的对象。我使用的命令看起来像这样:
tell application "Terminal"
get the id of the first window ¬
whose first tab's tty contains "003"
set w to result
close window id w
end tell
如果你想更清楚地了解事物,运行这个:
tell application “Terminal” to ¬
get every tab of every window
还有这个:
tell application “Terminal” to ¬
get properties of every window
还有这个:
tell application “Terminal” to ¬
get properties of tab 1 of every window
如果您的脚本的目的是打开选项卡和每个选项卡 运行 一个脚本,而不是在特定选项卡之间导航,您可以轻松修改脚本以在打开一个选项卡后执行脚本 in selected tab of front window
新标签,因为新标签总是被自动选中。这是我修改后的脚本:
tell application "Terminal"
activate
do script "YOUR SCRIPT 1" in tab 1 of front window
my makeTab()
do script "YOUR SCRIPT 2" in selected tab of front window
my makeTab()
do script "YOUR SCRIPT 3" in selected tab of front window
end tell
on makeTab()
tell application "System Events" to keystroke "t" using {command down}
delay 0.2
end makeTab
正如标题所说,我有一个苹果脚本可以:
in tab 2 of front window
过去工作正常,但自从 High Sierra 升级后 returns:
Terminal got an error: Can’t get tab 2 of window 1. (-1728)
对应于 errAENoSuchObject
我找不到关于此更改的任何文档 - 这是一个错误吗?有没有新的或更好的方法来做到这一点?
对象层次结构略有变化。每个选项卡在 AppleScript 中被引用为 tab 1 属于唯一的父 window 对象。
因此,以前,如果在一个 window 中打开三个选项卡,我们可以将它们称为 tab 1、tab 2 ,以及 选项卡 3,共 window 1。现在,我们有 tab 1 of window 1, tab 1 of window 2,以及 选项卡 1 of window 3.
我发现定位特定选项卡的最方便可靠的方法是识别包含 选项卡的 window 对象 具有特定 tty 属性 值的对象。我使用的命令看起来像这样:
tell application "Terminal"
get the id of the first window ¬
whose first tab's tty contains "003"
set w to result
close window id w
end tell
如果你想更清楚地了解事物,运行这个:
tell application “Terminal” to ¬
get every tab of every window
还有这个:
tell application “Terminal” to ¬
get properties of every window
还有这个:
tell application “Terminal” to ¬
get properties of tab 1 of every window
如果您的脚本的目的是打开选项卡和每个选项卡 运行 一个脚本,而不是在特定选项卡之间导航,您可以轻松修改脚本以在打开一个选项卡后执行脚本 in selected tab of front window
新标签,因为新标签总是被自动选中。这是我修改后的脚本:
tell application "Terminal"
activate
do script "YOUR SCRIPT 1" in tab 1 of front window
my makeTab()
do script "YOUR SCRIPT 2" in selected tab of front window
my makeTab()
do script "YOUR SCRIPT 3" in selected tab of front window
end tell
on makeTab()
tell application "System Events" to keystroke "t" using {command down}
delay 0.2
end makeTab