AutoHotkey写热键还是相当的容易

;这样就能实现右键菜单并发送T
;这里设置的热键是win+z
#z::
Send {AppsKey}
Sleep 200
Send  t

上面是整篇翻译。  而对于选中单词翻译,推荐以下方式:

; AutoHotkey版 谷歌翻译
; 用法:选中要翻译的文字,按两次Ctrl+C
; 热键:Ctrl+C, Ctrl+C
;--------------------------------------------------
#NoEnvDoublePress() ; Simulate double press
{static pressed1 = 0if pressed1 and A_TimeSincePriorHotkey <= 500{pressed1 = 0;Translate("en","ru") ; from English to Russiankeyword=%Clipboard%ToolTip % GoogleTranslate(keyword)}elsepressed1 = 1}~^C:: DoublePress()~LButton:: ; Remove tooltip left click
ToolTip
returnGoogleTranslate(str, from := "auto", to :=0)  {static JS := CreateScriptObj(), _ := JS.( GetJScript() ) := JS.("delete ActiveXObject; delete GetObject;")if(!to)             ; If no "to" parameter was passedto := GetISOLanguageCode()  ; Assign the system (OS) language to "to"if(from = to)           ; If the "from" and "to" parameters are the sameReturn str          ; Abort translation and return the original stringjson := SendRequest(JS, str, to, from, proxy := "")oJSON := JS.("(" . json . ")")if !IsObject(oJSON[1])  {Loop % oJSON[0].lengthtrans .= oJSON[0][A_Index - 1][0]}else  {MainTransText := oJSON[0][0][0]Loop % oJSON[1].length  {trans .= "`n+"obj := oJSON[1][A_Index-1][1]Loop % obj.length  {txt := obj[A_Index - 1]trans .= (MainTransText = txt ? "" : "`n" txt)}}}if !IsObject(oJSON[1])MainTransText := trans := Trim(trans, ",+`n ")elsetrans := MainTransText . "`n+`n" . Trim(trans, ",+`n ")from := oJSON[2]trans := Trim(trans, ",+`n ")Return trans
}; Take a 4-digit language code or (if no parameter) the current language code and return the corresponding 2-digit ISO code
GetISOLanguageCode(lang := 0) {LanguageCodeArray := { 0436: "af" ; Afrikaans, 041c: "sq" ; Albanian, 0401: "ar" ; Arabic_Saudi_Arabia, 0801: "ar" ; Arabic_Iraq, 0c01: "ar" ; Arabic_Egypt, 1001: "ar" ; Arabic_Libya, 1401: "ar" ; Arabic_Algeria, 1801: "ar" ; Arabic_Morocco, 1c01: "ar" ; Arabic_Tunisia, 2001: "ar" ; Arabic_Oman, 2401: "ar" ; Arabic_Yemen, 2801: "ar" ; Arabic_Syria, 2c01: "ar" ; Arabic_Jordan, 3001: "ar" ; Arabic_Lebanon, 3401: "ar" ; Arabic_Kuwait, 3801: "ar" ; Arabic_UAE, 3c01: "ar" ; Arabic_Bahrain, 042c: "az" ; Azeri_Latin, 082c: "az" ; Azeri_Cyrillic, 042d: "eu" ; Basque, 0423: "be" ; Belarusian, 0402: "bg" ; Bulgarian, 0403: "ca" ; Catalan, 0404: "zh-CN" ; Chinese_Taiwan, 0804: "zh-CN" ; Chinese_PRC, 0c04: "zh-CN" ; Chinese_Hong_Kong, 1004: "zh-CN" ; Chinese_Singapore, 1404: "zh-CN" ; Chinese_Macau, 041a: "hr" ; Croatian, 0405: "cs" ; Czech, 0406: "da" ; Danish, 0413: "nl" ; Dutch_Standard, 0813: "nl" ; Dutch_Belgian, 0409: "en" ; English_United_States, 0809: "en" ; English_United_Kingdom, 0c09: "en" ; English_Australian, 1009: "en" ; English_Canadian, 1409: "en" ; English_New_Zealand, 1809: "en" ; English_Irish, 1c09: "en" ; English_South_Africa, 2009: "en" ; English_Jamaica, 2409: "en" ; English_Caribbean, 2809: "en" ; English_Belize, 2c09: "en" ; English_Trinidad, 3009: "en" ; English_Zimbabwe, 3409: "en" ; English_Philippines, 0425: "et" ; Estonian, 040b: "fi" ; Finnish, 040c: "fr" ; French_Standard, 080c: "fr" ; French_Belgian, 0c0c: "fr" ; French_Canadian, 100c: "fr" ; French_Swiss, 140c: "fr" ; French_Luxembourg, 180c: "fr" ; French_Monaco, 0437: "ka" ; Georgian, 0407: "de" ; German_Standard, 0807: "de" ; German_Swiss, 0c07: "de" ; German_Austrian, 1007: "de" ; German_Luxembourg, 1407: "de" ; German_Liechtenstein, 0408: "el" ; Greek, 040d: "iw" ; Hebrew, 0439: "hi" ; Hindi, 040e: "hu" ; Hungarian, 040f: "is" ; Icelandic, 0421: "id" ; Indonesian, 0410: "it" ; Italian_Standard, 0810: "it" ; Italian_Swiss, 0411: "ja" ; Japanese, 0412: "ko" ; Korean, 0426: "lv" ; Latvian, 0427: "lt" ; Lithuanian, 042f: "mk" ; Macedonian, 043e: "ms" ; Malay_Malaysia, 083e: "ms" ; Malay_Brunei_Darussalam, 0414: "no" ; Norwegian_Bokmal, 0814: "no" ; Norwegian_Nynorsk, 0415: "pl" ; Polish, 0416: "pt" ; Portuguese_Brazilian, 0816: "pt" ; Portuguese_Standard, 0418: "ro" ; Romanian, 0419: "ru" ; Russian, 081a: "sr" ; Serbian_Latin, 0c1a: "sr" ; Serbian_Cyrillic, 041b: "sk" ; Slovak, 0424: "sl" ; Slovenian, 040a: "es" ; Spanish_Traditional_Sort, 080a: "es" ; Spanish_Mexican, 0c0a: "es" ; Spanish_Modern_Sort, 100a: "es" ; Spanish_Guatemala, 140a: "es" ; Spanish_Costa_Rica, 180a: "es" ; Spanish_Panama, 1c0a: "es" ; Spanish_Dominican_Republic, 200a: "es" ; Spanish_Venezuela, 240a: "es" ; Spanish_Colombia, 280a: "es" ; Spanish_Peru, 2c0a: "es" ; Spanish_Argentina, 300a: "es" ; Spanish_Ecuador, 340a: "es" ; Spanish_Chile, 380a: "es" ; Spanish_Uruguay, 3c0a: "es" ; Spanish_Paraguay, 400a: "es" ; Spanish_Bolivia, 440a: "es" ; Spanish_El_Salvador, 480a: "es" ; Spanish_Honduras, 4c0a: "es" ; Spanish_Nicaragua, 500a: "es" ; Spanish_Puerto_Rico, 0441: "sw" ; Swahili, 041d: "sv" ; Swedish, 081d: "sv" ; Swedish_Finland, 0449: "ta" ; Tamil, 041e: "th" ; Thai, 041f: "tr" ; Turkish, 0422: "uk" ; Ukrainian, 0420: "ur" ; Urdu, 042a: "vi"} ; VietnameseIf(lang)Return LanguageCodeArray[lang]Else Return LanguageCodeArray[A_Language]
}
SendRequest(JS, str, tl, sl, proxy) {ComObjError(false)http := ComObjCreate("WinHttp.WinHttpRequest.5.1")( proxy && http.SetProxy(2, proxy) );~ http.open( "POST", "https://translate.google.com/translate_a/single?client=webapp&sl="http.open( "POST", "https://translate.google.cn/translate_a/single?client=webapp&sl=". sl . "&tl=" . tl . "&hl=" . tl. "&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=0&ssel=0&tsel=0&pc=1&kc=1". "&tk=" . JS.("tk").(str), 1 )http.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8")http.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")http.send("q=" . URIEncode(str))http.WaitForResponse(-1)Return http.responsetext
}URIEncode(str, encoding := "UTF-8")  {VarSetCapacity(var, StrPut(str, encoding))StrPut(str, &var, encoding)While code := NumGet(Var, A_Index - 1, "UChar")  {bool := (code > 0x7F || code < 0x30 || code = 0x3D)UrlStr .= bool ? "%" . Format("{:02X}", code) : Chr(code)}Return UrlStr
}GetJScript()
{script =(var TKK = ((function() {var a = 561666268;var b = 1526272306;return 406398 + '.' + (a + b);})());function b(a, b) {for (var d = 0; d < b.length - 2; d += 3) {var c = b.charAt(d + 2),c = "a" <= c ? c.charCodeAt(0) - 87 : Number(c),c = "+" == b.charAt(d + 1) ? a >>> c : a << c;a = "+" == b.charAt(d) ? a + c & 4294967295 : a ^ c}return a}function tk(a) {for (var e = TKK.split("."), h = Number(e[0]) || 0, g = [], d = 0, f = 0; f < a.length; f++) {var c = a.charCodeAt(f);128 > c ? g[d++] = c : (2048 > c ? g[d++] = c >> 6 | 192 : (55296 == (c & 64512) && f + 1 < a.length && 56320 == (a.charCodeAt(f + 1) & 64512) ?(c = 65536 + ((c & 1023) << 10) + (a.charCodeAt(++f) & 1023), g[d++] = c >> 18 | 240,g[d++] = c >> 12 & 63 | 128) : g[d++] = c >> 12 | 224, g[d++] = c >> 6 & 63 | 128), g[d++] = c & 63 | 128)}a = h;for (d = 0; d < g.length; d++) a += g[d], a = b(a, "+-a^+6");a = b(a, "+-3^+b+-f");a ^= Number(e[1]) || 0;0 > a && (a = (a & 2147483647) + 2147483648);a `%= 1E6;return a.toString() + "." + (a ^ h)})Return script
}CreateScriptObj() {static docdoc := ComObjCreate("htmlfile")doc.write("<meta http-equiv='X-UA-Compatible' content='IE=9'>")Return ObjBindMethod(doc.parentWindow, "eval")
}

[AHK]双击Ctrl+C调用谷歌翻译!相关推荐

  1. php调用谷歌翻译,PHP调用谷歌翻译 | 学步园

    /* * PHP调用谷歌翻译 * author:cc * date:2012/5/4 */ function translate($text,$language='zh-cn|en'){ if(emp ...

  2. qq浏览器网页翻译_如何通过Edge浏览器调用“谷歌翻译”,将整个网页翻译为中文...

    调用谷歌翻译,需要用到"油猴"插件,以及"网页翻译助手"脚本,只要你安装,就可以直接将网页翻译为中文. 介绍: 油猴介绍:Tampermonkey(油猴脚本)是 ...

  3. 如何在listary中调用谷歌翻译

    文章目录 如何在listary中调用谷歌翻译 1具体设置 2测试一下 3跳转到浏览器 如何在listary中调用谷歌翻译 listary是一个非常好用的电脑搜索软件,我们也可以用它来web定位搜索. ...

  4. Python 调用谷歌翻译(2021年3月测试可用)

    前言 把之前的用来谷歌翻译的Python文件整理了下, 用来处理翻译下i18n.js所需要的字典, 直接调用即可.2021年3月测试可用 (¦3[▓▓] 2021年9月17日 测试失效 请查看: Py ...

  5. node调用谷歌翻译Api,实现自动国际化

    原因: 项目国际化过程繁琐,每次都需要人工去google翻译,导致工作效率不高. 需求: 1.减少人工的重复劳动,提高工作效率. 2.使用脚本调用谷歌翻译接口自动化翻译. 3.free,作为程序员肯定 ...

  6. 谷歌翻译退出中国市场,想要免费的调用谷歌翻译的接口,有什么好的解决办法呢?

    谷歌翻译退出中国市场,想要免费的调用谷歌翻译的接口,有什么好的解决办法呢? https://translate.googleapis.com/translate_a/single?client=gtx ...

  7. Python3 调用谷歌翻译 英汉互译

    Python3 调用谷歌翻译 将英文翻译成中文 代码如下: import urllib.request import execjsclass Py4Js():def __init__(self):se ...

  8. siri捷径调用谷歌翻译_告诉它使用Google助理,以减少Siri的麻烦

    siri捷径调用谷歌翻译 When it comes to the Digital Assistant Wars™, one thing is abundantly clear regardless ...

  9. python调用谷歌翻译英文文献pdf_Python 调用 Google Translate API 批量翻译文章

    有时候批量翻译中文文章,批量变成各个小语种的语言,手动的粘贴复制是非常慢的.需要调用翻译 API 接口,综合对比市面上的各个翻译 API,个人觉得 Google 的翻译 API 最为好用和准确. 下面 ...

  10. python调用谷歌翻译__201907

    2019年7月4日15:53:17(¦3[▓▓] 晚安 谷歌翻译环境 Python 3.6 第三方库 Execjs (pip install PyExecJS) 文件列表 同目录下的四个文件:- to ...

最新文章

  1. 手机屏幕的物理分辨率和逻辑分辨率
  2. CMake常见变量——Project和CMake相关信息
  3. 网站添加到IIS和附件进程调试(新手使用篇)
  4. [Android] 任意时刻从子线程切换到主线程的实现
  5. 【并查集】并查集的基本操作总结
  6. JavaScript实用小技巧
  7. 树莓派安装FFTW,linux安装库不生成.so库,拷贝.so .a,按时间查看文件的命令
  8. project甘特图导出图片_Project将任务及甘特图导出Excel的方法
  9. 如何给域名前加上 www
  10. 约束的操作 - 增加 删除 禁止 启用
  11. 网页POST之文件上传专项视频教程
  12. 常见出血性疾病的实验诊断题库【1】
  13. zc706开发板的linux开发,第一篇:zc706 开箱及开发环境搭建
  14. cNc数控Z轴服务器在什么位置,五轴数控机床A、C旋转轴分别安装在哪里?
  15. 小京东 去版权 去后门 终极版 ecshop
  16. appinventor认识
  17. excel表格分割线一分为二_Anki+思维导图的两种方法(Anki+表格,Anki+幕布)
  18. 蓝牙知识二【FEATURE SUPPORT】【LL_PING】【 LL_LENGTH】【Private Device Address Generatio】【profile例子EXAMPLE ATT】
  19. 【毕业季·进击的技术er】 什么是微信小程序,带你推开小程序的大门
  20. 着陆攻击LAND Attack

热门文章

  1. 【UI】NGUI和UGUI
  2. Linux下输入法切换快捷键设置
  3. 计算机2017语言排名,2017计算机编程语言排行榜 java依然独占鳌头
  4. 怎么用计算机画图工具,使用电脑自带画图工具(画图软件怎样操作的方法
  5. gsonformat java代码_AndroidStudio插件GsonFormat快速实现JavaBean
  6. python怎么通过手机号定位_基于Python的免费手机号码归属地查询
  7. 飞秋mac版字符乱码_Mac版QQ的OCR文字识别功能究竟有多好用?
  8. 主板在计算机系统中的应用,浅谈主板在计算机硬件系统中的重要性.doc
  9. 21个以Bootstrap为框架的WordPress免费主题模板下载
  10. Java连接数据库(二):数据库连接池(druid)