【发布时间】:2016-09-01 02:33:14
【问题描述】:
我正在制作一个 Applescript 服务,它接收选定的文本并使用该文本打开一个谷歌查询。这是它的第一个版本:
on run {input, parameters}
set myBrowser to http://google.com.br?q=" & input as text
set the_url to "Safari" as text
tell application myBrowser
open location "http://google.com.br?q=" & input
set the bounds of the front window to {100, 22, 800, 1024}
activate
end tell
end run
上面这个效果很好。当我试图让浏览器打开一个带有查询的新页面而不是一个新选项卡时,问题就来了。我必须想出一个解决方案,因为它不会在新窗口中打开两个选项卡,因为它会在触发脚本并关闭 Safari 时发生:
on run {input, parameters}
set the_url to "http://google.com.br?q=" & input
set myBrowser to "Safari" as text
set aWindowIsOpen to false
tell application myBrowser
repeat with thisWindow in windows
if (not miniaturized of thisWindow) then
set aWindowIsOpen to true
end if
end repeat
if (aWindowIsOpen) then
make new document with properties {URL:the_url}
set the bounds of the front window to {100, 22, 800, 1024}
activate
else
activate
make new document with properties {URL:the_url}
set the bounds of the front window to {100, 22, 800, 1024}
activate
end if
end tell
end run
所以现在的问题是浏览器无法打开 URL。有什么想法吗?
【问题讨论】:
标签: applescript