如何使用 rb-appscript 激活特定的 Safari 窗口?
我无法让 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)
I can't get rb-appscript to activate a specific Safari window. It is always activating the most recently active window.
(in irb, assuming rb-appscript is already installed)
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/"
Now here comes the hairy part. Activating documents[3] should activate the google window, but this isn't what is happening.
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法
激活
窗口:
You can't
activate
windows: