首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用rb-appscript激活特定的Safari窗口?

如何使用rb-appscript激活特定的Safari窗口?
EN

Stack Overflow用户
提问于 2011-07-13 20:30:38
回答 1查看 550关注 0票数 0

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

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

代码语言:javascript
复制
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/"

现在是毛发的部分了。激活documents3应该会激活谷歌窗口,但实际情况并非如此。

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-07-13 20:41:24

你不能activate窗口:

代码语言:javascript
复制
app("Safari").windows[its.name.eq("Google")].index.set(1)
代码语言:javascript
复制
tell application "Safari" to set index of (windows where name is "Google") to 1
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6678899

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档