我正在制作一个Applescript服务,它接收选定的文本并使用此文本打开一个google查询。这是它的第一个版本:
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。有什么想法吗?
发布于 2016-08-31 18:33:14
使用tell application "Safari"而不是tell application myBrowser。
或者,使用using terms from application "Safari",如下所示:
将myBrowser设置为"Safari“,使用来自应用程序的术语"Safari”告诉应用程序myBrowser使用
https://stackoverflow.com/questions/39254681
复制相似问题