激活不可编写脚本的窗口(XCode 风格)

发布于 2025-01-01 11:56:38 字数 456 浏览 0 评论 0原文

我想激活不可编写脚本的应用程序的特定窗口,并决定仅使用 XCode 作为示例。所以这里有一个设置:

  1. 启动 Xcode,打开一些项目(我打开了 Son of Grab)
  2. 双击源文件以打开源窗口(在我的例子中为 Controller.m)
  3. 选择窗口|管理器打开管理器窗口

    • 此时您将拥有三个 Xcode 窗口、一个项目(主)窗口、组织器和一个源窗口。
  4. 聚焦源(在我的例子中再次是 Controller.m)窗口。

  5. 尝试将“组织器 - 文档”窗口聚焦在脚本中;我的简单做法是:

    告诉应用程序“Xcode” 激活窗口“组织者 - 文档” end Tell

此命令后,在我运行脚本之前聚焦的源窗口将再次聚焦 - 但不是组织器窗口。

我缺少什么?感谢大家!

I'd like to activate a particular window of a nonscriptable app, and decided to just use XCode as an exemplar. So here's one setup:

  1. Launch Xcode, open some project (I opened Son of Grab)
  2. Double click a source file to open a source window (Controller.m in my case)
  3. Select Window | Organizer to open the Organizer window

    • at this point you'll have three Xcode windows, a project (main) one, the Organizer, and a source window.
  4. Focus the source (again Controller.m in my case) window.

  5. Try to focus the "Organizer - Documentation" window in a script; my simpleminded approach was:

    tell application "Xcode"
    activate window "Organizer - Documentation"
    end tell

After this runs, the source window that was focused before I ran the script will again be focused - but not the Organizer window.

What am I missing? Thanks to all!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半衾梦 2025-01-08 11:56:38

activate 命令将应用程序置于最前面。每个应用程序都有自己的术语来处理其文档,因此您需要查看脚本字典。在 Xcode 中,看起来您可以通过设置文档的索引(通常是从前到后的顺序)来获得您想要的内容,例如,使用您的代码片段:

tell application "Xcode"
    activate
    set index of window "Organizer - Documentation" to 1
end tell

The activate command brings the application to the front. Each application will have its own terminology for dealing with its documents, so you would need to look at the scripting dictionary. In Xcode, it looks like you can get what you want by setting the index of the document (usually the front to back ordering), for example, using your snippet:

tell application "Xcode"
    activate
    set index of window "Organizer - Documentation" to 1
end tell
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文