根据使用 applescript 的内容和最佳实践,在终端中选择特定选项卡
这是一个特定于应用程序的问题。我试图根据其中的内容在 Terminal.app 中查找并选择一个选项卡。这就是我正在做的事情:
tell application "Terminal"
set foundTabs to (every tab of every window) whose contents contains "selectme"
repeat with possibleTab in foundTabs
try
set selected of possibleTab to true
end try
end repeat
end tell
这并不像预期的那样,而且非常万无一失。我想知道是否有人可以建议一种用更少的代码来完成此操作的方法(例如,循环实际上不是必要的,但 applescript 是一种难以捉摸的语言)。
谢谢
This is an application specific problem. I am trying to find and select a tab in Terminal.app depending on contents within. Here is what I'm doing:
tell application "Terminal"
set foundTabs to (every tab of every window) whose contents contains "selectme"
repeat with possibleTab in foundTabs
try
set selected of possibleTab to true
end try
end repeat
end tell
This isn't acting as expected and is pretty foolproof. I wonder if someone can suggest a way to do this with much less code (for instance, the looping shouldn't really be necessary, but applescript is an elusive language).
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实是,以下 Applescript 将执行您想要的操作,但除非您的“selectme”字符串非常独特,否则您会在许多选项卡中找到它。
但无论如何,给你:
Thing is, the following Applescript will do what you want, but unless your "selectme" string is very unique, you will find it in many tabs.
But anyway, here you go: