0

我无法让 rb-appscript 激活特定的 Safari 窗口。它总是激活最近活动的窗口。

(在 irb 中,假设 rb-appscript 已经安装)

require 'appscript'
include Appscript

safari = app 'Safari'
safari.open_location "http://www.google.com"
safari.open_location "http://www.apple.com"
safari.open_location "http://www.bing.com"
safari.documents.URL.get
=> ["http://www.bing.com/", "http://www.apple.com/", "http://www.google.com.ph/", "http://www.apple.com/startpage/"]
safari.documents[1].URL.get
 => "http://www.bing.com/"
safari.documents[3].URL.get
 => "http://www.google.com.ph/"

现在到了毛茸茸的部分。激活文档[3] 应该激活谷歌窗口,但这不是正在发生的事情。

safari.documents[3].activate
 => nil (activates the bing window instead of the google window)
safari.windows[3].activate
 => nil (activates the bing window instead of the google window)
4

1 回答 1

3

你不能activate窗口:

app("Safari").windows[its.name.eq("Google")].index.set(1)

 

tell application "Safari" to set index of (windows where name is "Google") to 1
于 2011-07-13T12:41:23.937 回答