美文网首页macOS/iOS自动化指南
Automator实现右键百度翻译

Automator实现右键百度翻译

作者: 鸭梨山大哎 | 来源:发表于2017-02-12 21:51 被阅读48次

打开Automator,新建service
接着

Paste_Image.png

第二步,选择run applescript

on run {input, parameters}
    set output to "http://fanyi.baidu.com/?aldtype=16047&tpltype=sigma#en/zh/" & urldecode(input as string)
    return output
    
end run
on urldecode(x)
    set cmd to "'require \"cgi\"; puts CGI.escape(STDIN.read.chomp).gsub(\"+\",\"%20\")'"
    do shell script "echo " & quoted form of x & " | ruby -e " & cmd
end urldecode

第三步,如图

Paste_Image.png

使用是右键就可以了

Paste_Image.png

同时给出一个朗文词典的办法,修改第二步的代码就可以了!

on run {input, parameters}
    set output to "http://www.ldoceonline.com/dictionary/" & input as string
    return output
end run

有道词典

on run {input, parameters}
    set output to ("http://m.youdao.com/dict?le=eng&q=" & input as string)
    return output
end run

当然啦,这些用popclip也可以实现,不过那个要跳转,比较麻烦!

相关文章

网友评论

    本文标题:Automator实现右键百度翻译

    本文链接:https://www.haomeiwen.com/subject/qatzittx.html