gpt4 book ai didi

terminal - 在前窗口的选项卡 2 中返回自 High Sierra 更新以来终端出现错误 : Can’t get tab 2 of window 1. (-1728)

转载 作者:行者123 更新时间:2023-12-02 19:33:19 27 4
gpt4 key购买 nike

正如标题所说,我有一个 Apple 脚本,它可以:

in tab 2 of front window

...过去运行良好,但自从 High Sierra 升级返回后:

Terminal got an error: Can’t get tab 2 of window 1. (-1728)

对应于 errAENoSuchObject 我找不到任何有关此更改的文档 - 这是一个错误吗?有没有新的或更好的方法来做到这一点?

最佳答案

对象层次结构略有变化。每个选项卡在 AppleScript 中都被引用为属于唯一父窗口对象的选项卡 1

因此,以前,如果在一个窗口中打开了三个选项卡,我们可以将它们称为选项卡 1选项卡 2选项卡 3 窗口 1。现在,我们有窗口 1选项卡 1窗口 2选项卡 1选项卡 1 窗口 3

我发现定位特定选项卡的最方便、最可靠的方法是识别包含具有特定 tty 的 tab 对象的 window 对象属性(property)值(value)。我使用的命令如下所示:

    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

关于terminal - 在前窗口的选项卡 2 中返回自 High Sierra 更新以来终端出现错误 : Can’t get tab 2 of window 1. (-1728),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47714464/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com