开发者

Applescript activate closed window

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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜