首页 > 解决方案 > 在 URL 中使用 unicode 从 Automator 打开 Chrome 失败

问题描述

我正在使用 Automator 根据一些选定的文本在 Chrome 中打开一个链接:

on run {input, parameters}
    set kanji to input as string
    set link to "https://jisho.org/search/" & kanji
    tell application "Google Chrome"
        open location link
    end tell
end run

当输入文本是 ASCII 时,这可以正常工作,并且在 URL 处打开一个新的 Chrome 选项卡,但是当输入文本是汉字(例如汉字)时,什么也没有发生(并且放在“try”块中时没有错误)。打开“Safari”总是正常工作,所以这看起来像 Chrome 的东西?

铬 91.0.4472.164,macOS 11.3。

感谢您的任何见解!

更新:感谢行和 gurkensaas。

我最终得到了这个工作版本:

on run {input, parameters}
    set kanji to input as string
    set link to "https://jisho.org/search/" & kanji
    try
        tell application "Google Chrome"
            tell its window 1
                set URL of (make new tab) to link
                end tell
        end tell
    on error errMsg number errorNumber
        display dialog "Error occurred:  " & errorNumber as text
    end try
end run

标签: google-chromeunicodeautomator

解决方案


推荐阅读