开发者

How do I make a Safari window active using AppleScript (elegantly)?

While one can simulate c开发者_如何学编程ommand-shift-` using System Events to change windows in Safari, is there no better way to do this with AppleScript? I can change the index of Safari's windows, this changes their ordering on the screen but does not make them active. Suppose you have two Safari windows containing about:blank -- how could you bring the one in the back to the front and make it active?

Granted, command-shift-` works, so maybe there only needs to be one way to skin this cat.


I also noticed that changing the index does reorder the windows however the new window does not actually come to the front. By playing around I found you can fix that by playing with the "visible" property...

tell application "Safari"
    set theWindows to windows
    set win2 to item 2 of theWindows
    tell win2
        set visible to false
        set visible to true
        set index to 1
    end tell
end tell
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜