Applescript 激活关闭的窗口

发布于 2024-09-25 21:21:28 字数 377 浏览 4 评论 0原文

如何激活应用程序并使其打开“标准”窗口,就像我使用 applescript 单击停靠图标一样?

例如,我在 iTunes 中,使用 command-w 打开另一个应用程序关闭窗口,然后单击 iTunes 停靠图标,iTunes 成为最前面的应用程序并打开它的“标准”iTunes 窗口。

当我想用 applescript 模拟时,我输入:

tell application iTunes to activate

然后发生的情况是,iTunes 成为最前面的应用程序,但“标准”窗口(在这种情况下是 iTunes 窗口)没有打开。

有谁知道使用任何应用程序的通用方法打开“标准”窗口的方法?

谢谢 b00tsy

how can I activate an application and make it open the "standard" window as if I would have clicked on the dock icon with applescript?

E.g. I am in iTunes, close the window with command-w open another application and then I click on the iTunes dock icon and iTunes becomes the frontmost application and opens up it's "standard" iTunes window.

When I want to simulate that with applescript I type:

tell application iTunes to activate

What happens then is, that iTunes becomes the frontmost application, but the "standard" window (in that case the iTunes window) isn't being opened.

Does anyone know about a way to open the "standard" window with a general approach for any application?

Thanks b00tsy

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

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

发布评论

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

评论(2

夏雨凉 2024-10-02 21:21:28

很长一段时间后,我发现我期望发生的事情

tell application "anyApplication" activate

实际上发生了

tell application "anyApplication" reopen

after a long time I found out that what I expect to happen with

tell application "anyApplication" activate

actually happens with

tell application "anyApplication" reopen
眼眸里的快感 2024-10-02 21:21:28

没有真正的、单一的方法来显示“标准”窗口。由每个应用程序的开发人员决定如何创建和显示窗口。例如,这里是 iTunes 和 Microsoft Word 2008...

tell application "iTunes"
   activate
   set theBrowser to browser window 1
   set visible of theBrowser to true
end tell

tell application "Microsoft Word"
   set newDocument to make new document
end tell

在 iTunes 中,存在三个“标准”窗口 - 浏览器、EQ 和播放列表 - 并且浏览器和 EQ始终 存在。但在 Microsoft Word 中,我们必须创建一个新文档,该文档尽可能接近“标准”。 大多数应用程序的工作方式与 Word 相同,但这并不能保证,您必须查看给定应用程序的词典以了解它如何处理窗口(尽管 iTunes 确实有 code>window 类让大家失望,但这就是为你准备的 Applescript...)。

还有一件事需要注意......在大多数情况下,一旦窗口关闭,重新打开它的唯一方法是打开填充刚刚创建的窗口的文件,或者只是创建一个新窗口。 iTunes 的实施很少见。

There is no true, single way to show a "standard" window. It is up to the developer of each application to decide how a window is to be created and shown. For example, here is iTunes and Microsoft Word 2008...

tell application "iTunes"
   activate
   set theBrowser to browser window 1
   set visible of theBrowser to true
end tell

tell application "Microsoft Word"
   set newDocument to make new document
end tell

In iTunes, there are three "standard" windows—browser, EQ, and playlist—and browser and EQ always exist. But in Microsoft Word, however, we have to make a new document, which is as close to a "standard" as it gets. Most applications will work the same way Word does, but it isn't a guarantee and you will have to look at the Dictionary for a given application to see how it handles windows (although iTunes does have a window class to throw everyone off, but that's Applescript for ya...).

One more thing to note...in most cases, once a window is closed, the only way to reopen it is to open the file that populated the window you just created or simply create a new one. iTunes is rare in its implementation.

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