从Applescript在谷歌浏览器中打开IP

时间:2011-11-19 11:03:43

标签: url shell browser applescript ip

我一直在尝试使用Apple Chrome和safari中的shell脚本打开一个ip,但是没有成功。到目前为止,我一直在尝试这样的开放命令:

do shell script "open http://" & blockedIP

当我将blockedIP替换为URL时有效,但是当我尝试使用IP时,它只会打开一个带有默认主页和地址栏中IP的新选项卡。我也尝试了其他几种方法,但每种方法都不起作用或与此相同。有谁知道我怎么能这样做?

1 个答案:

答案 0 :(得分:2)

试试这个。

tell application "Safari"
    make new document at end of documents
    set URL of document 1 to "http://" & blockedIP
end tell

这不使用shell脚本来完成工作,它使用直接的Safari AppleScripting(因为它是可编写脚本的。) 如果您想在Google Chrome上执行相同操作,请使用:

tell application "Google Chrome"
    make new window with properties {mode:"normal"}
    set URL of active tab of window 1 to "http://" & blockedIP
end tell
相关问题