我无法让 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)