Envy, I am sure that there already is php wrapper.
You need just google it.
Using Google Translate to automate text translation
Re: Using Google Translate to automate text translation
is possible to read the text content of a website?
like:
https://www.autohotkey.com
if I go to autohotkey.com and do a ctrl+c my clipboard will look like:
like:
https://www.autohotkey.com
if I go to autohotkey.com and do a ctrl+c my clipboard will look like:
Spoiler
im ask because if i could read this content i could store it and then translate @teadrinker-
- Posts: 4391
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Using Google Translate to automate text translation
@c7aesa7r It depends on your browser. Anyway, this question is off-topic here. Ask in «Ask For Help» please.
-
- Posts: 46
- Joined: 07 May 2020, 07:02
Re: Using Google Translate to automate text translation
Great work! I am in the process of using this and having the translate function work on highlighted words translate into a tooltip box. However, run into a problem I cannot work out at my current level. I am trying to do Japanese > English or Auto > Japanese. works just fine but when I try or any other combination like ja or GoogleTranslate(str, from := "en", to := "ja")
The tooltip does not update nor translate. If There is a number or Latin based letter it will translate the entire selected passage, but only then.
If anyone could give some guidance on how to solve this, would much appreciate.
Currently my script looks like this, with the word being saved to clipboard automatically.
If there are any better ways to implement all of this too, I am willing to learn. Thanks!
Code: Select all
GoogleTranslate(str, from := "auto", to := "en")
Code: Select all
GoogleTranslate(str, from := "auto", to := "jp")
The tooltip does not update nor translate. If There is a number or Latin based letter it will translate the entire selected passage, but only then.
If anyone could give some guidance on how to solve this, would much appreciate.
Currently my script looks like this, with the word being saved to clipboard automatically.
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
clipboard := ""
clipboard := clipboard
~LButton::
Loop, {
MouseGetPos, x, y
KeyWait, LButton
MouseGetPos, x0, y0
If (abs(x-x0) > 1 or abs(y-y0) > 1){
Send ^c
ClipWait
If (RegExmatch(clipboard, "[^\x00-\x7F]")) { ; WORKS
Tooltip, % GoogleTranslateEN(clipboard)
}
Else {
Tooltip, % GoogleTranslateJP(clipboard) ;DOES NOT WORK
}
}
}
Return
GoogleTranslateEN(str, from := "auto", to := "en") {
static JS := CreateScriptObj(), _ := JS.( GetJScript() ) := JS.("delete ActiveXObject; delete GetObject;")
json := SendRequest(JS, str, to, from, proxy := "")
oJSON := JS.("(" . json . ")")
if !IsObject(oJSON[1]) {
Loop % oJSON[0].length
trans .= 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 ")
else
trans := MainTransText . "`n+`n" . Trim(trans, ",+`n ")
from := oJSON[2]
trans := Trim(trans, ",+`n ")
Return trans
}
GoogleTranslateJP(str, from := "auto", to := "ja") {
static JS := CreateScriptObj(), _ := JS.( GetJScript() ) := JS.("delete ActiveXObject; delete GetObject;")
json := SendRequest(JS, str, to, from, proxy := "")
oJSON := JS.("(" . json . ")")
if !IsObject(oJSON[1]) {
Loop % oJSON[0].length
trans .= 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 ")
else
trans := MainTransText . "`n+`n" . Trim(trans, ",+`n ")
from := oJSON[2]
trans := Trim(trans, ",+`n ")
Return trans
}
SendRequest(JS, str, tl, sl, proxy) {
static http
ComObjError(false)
if !http
{
http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
( proxy && http.SetProxy(2, proxy) )
http.open( "get", "https translate.google.com ", Broken Link for safety 1 )
http.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
http.send()
http.WaitForResponse(-1)
}
http.open( "POST", "https translate.google.com /translate_a/single?client=webapp&sl=" Broken Link for safety
. 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 doc
doc := ComObjCreate("htmlfile")
doc.write("<meta http-equiv='X-UA-Compatible' content='IE=9'>")
Return ObjBindMethod(doc.parentWindow, "eval")
}
If there are any better ways to implement all of this too, I am willing to learn. Thanks!
-
- Posts: 4391
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Using Google Translate to automate text translation
@kairushinjuu
Code: Select all
; to en
MsgBox, % GoogleTranslate("こんにちは世界!",, "en")
; to ja
MsgBox, % GoogleTranslate("Hello, World!",, "ja")
Re: Using Google Translate to automate text translation
Code: Select all
~LButton::
;Loop, {
clipboard := ""
MouseGetPos, x, y
KeyWait, LButton
MouseGetPos, x0, y0
If (abs(x-x0) > 1 or abs(y-y0) > 1){
Send ^c
ClipWait, 0
If (RegExmatch(clipboard, "[^\x00-\x7F]")) { ; WORKS
Tooltip, % GoogleTranslate(clipboard)
} Else {
Tooltip, % GoogleTranslate(clipboard,, "ja") ;DOES WORK
}
}
;}
Return
~Esc:: ToolTip
#Include GoogleTranslate.ahk ; use original function!
-
- Posts: 46
- Joined: 07 May 2020, 07:02
Re: Using Google Translate to automate text translation
Thanks @rommmcek Just to be sure with the include .ahk part are you referring to Teadrinkers code on the first page? Or any of the other iterations spread throughout this thread?
-
- Posts: 46
- Joined: 07 May 2020, 07:02
Re: Using Google Translate to automate text translation
Thank you @rommmcek especially for helping me see how to improve my code ^^ and @teadrinker. This is perfect! One last request/question I saw a few replies back that someone else also wanted to add the romaji spelling or hiragana spelling for Japanese words. The transliteration, how would one go about also incorporating this?
-
- Posts: 4391
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Using Google Translate to automate text translation
Since I don't know Japanese, I can't help, sorry.
Re: Using Google Translate to automate text translation
Global Hotkeys:
F1, F5: Copy marked text and traslate it
- if there is no marked text attempts to auto-mark a word and then copy it - should work I text editors.
- if there is no marked text and IE active in youtube and subtitles visible attempts to capture them (working as of jan 26 2021)
- if there is no marked text and mpc-hc active and srt subtitles on attempts to capture them (if present in the specified path)
F2: Show Last Gui
Context sensitive Hotkeys (Main Gui Active):
Esc: Stop Google speech if it is running otherwise Hide Gui (Click on Minimize Gui Hides it too - not Minimize)
!Left and XButton1: History Back
!Right and XButton2: History Forward
^Del and !x: Delete History Item (Click on Close Gui Deletes History item too - not Close)
!Up and !Down: Expand/Shrink History capacity
F2: Show Select Language Gui
F3: Replay last speech
F4: Pause/Unpause current speech
F5: Stop the current speech
F9:: Start Speech Input
F10: Start Speech Output
^!#Esc: ExitApp
Context sensitive Hotkeys (Select Language Gui Active):
^Enter: Close Select Language Gui and set chosen settings (Click on Close Gui does the same - not just Close Gui)
Esc:: Close Select Language Gui w/o changing lang. settings
P.s.: As ever: Big thanks to teadrinker!
F1, F5: Copy marked text and traslate it
- if there is no marked text attempts to auto-mark a word and then copy it - should work I text editors.
- if there is no marked text and IE active in youtube and subtitles visible attempts to capture them (working as of jan 26 2021)
- if there is no marked text and mpc-hc active and srt subtitles on attempts to capture them (if present in the specified path)
F2: Show Last Gui
Context sensitive Hotkeys (Main Gui Active):
Esc: Stop Google speech if it is running otherwise Hide Gui (Click on Minimize Gui Hides it too - not Minimize)
!Left and XButton1: History Back
!Right and XButton2: History Forward
^Del and !x: Delete History Item (Click on Close Gui Deletes History item too - not Close)
!Up and !Down: Expand/Shrink History capacity
F2: Show Select Language Gui
F3: Replay last speech
F4: Pause/Unpause current speech
F5: Stop the current speech
F9:: Start Speech Input
F10: Start Speech Output
^!#Esc: ExitApp
Context sensitive Hotkeys (Select Language Gui Active):
^Enter: Close Select Language Gui and set chosen settings (Click on Close Gui does the same - not just Close Gui)
Esc:: Close Select Language Gui w/o changing lang. settings
P.s.: As ever: Big thanks to teadrinker!
- Attachments
-
- Google Translate json_History 2.56.ahk
- (35.29 KiB) Downloaded 224 times
Last edited by rommmcek on 26 Jan 2021, 09:43, edited 5 times in total.
Re: Using Google Translate to automate text translation
@rommmcek
@teadrinker
thank you for the scripts , very useful
at page-1 an easy script , teadrinker's script with GUI , dropdownlist ( select language to translate ) and audio-button ( maybe can be done better )
@teadrinker
thank you for the scripts , very useful
at page-1 an easy script , teadrinker's script with GUI , dropdownlist ( select language to translate ) and audio-button ( maybe can be done better )
-
- Posts: 18
- Joined: 28 Jul 2020, 03:58
Re: Using Google Translate to automate text translation
hi, i'm a new AHKer. I'm really impressive with your script about this translation. But because i'm new ) so i wanna know how to do when i translate from clipboard. Is this % GoogleTranslate(clipboard) or what? Sorry if this bothers youteadrinker wrote: ↑27 Feb 2020, 07:25r2997790Code: Select all
res := GoogleTranslate("今日",, "en") MsgBox, % res MsgBox, % RegExReplace(res, "s)\R\+.+")
-
- Posts: 4391
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Using Google Translate to automate text translation
@phucnguyenphi123
If you need to translate the Clipboard contents from some language to English, this is the right way.
If you need to translate the Clipboard contents from some language to English, this is the right way.
-
- Posts: 46
- Joined: 07 May 2020, 07:02
Re: Using Google Translate to automate text translation
@rommmcek That is amazing and I will probably have a use for it, but at the moment I really only need it to just open the tooltip ater highlighting a word or sentence translate it to the appropriate language and if that language be Japanese in the same tool tip if possible or a separate one underneath/next too provide the spelling of the word in latin characters. What you gave me is awesome but a bit overkill for my current needs and I am not sure looking at just the code what bits I need to make it happen.. Thanks anyway. If you could help cut it down for me I would be super grateful!
-
- Posts: 18
- Joined: 28 Jul 2020, 03:58
Re: Using Google Translate to automate text translation
Thank you, i did it. Such a powerful tool for meteadrinker wrote: ↑28 Jul 2020, 06:34@phucnguyenphi123
If you need to translate the Clipboard contents from some language to English, this is the right way.
Re: Using Google Translate to automate text translation
@kairushinjuu: Sure no problem!This is a quick trim, hope there's no bug!
@garry: I merged the two scripts, improved consecutive speech, added history counter, added Gui to select/swap languages, reduced global hotkeys to 2, added expand/shrink history... But have no time and will currently to write instructions... It's now still a bit more an "overkill"! Let's make a deal! I publish the code, and you write the instructions (all hotkeys have all comments)?
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance, Force
CoordMode, Mouse, Screen
SoundBeep, 2500
Return
~LButton::
clipboard := ""
MouseGetPos, x, y
KeyWait, LButton
MouseGetPos, x0, y0
If (abs(x-x0) > 1 or abs(y-y0) > 1){
Send ^c
ClipWait, 0
If (RegExmatch(clipboard, "[^\x00-\x7F]")) { ; WORKS
r:= GoogleTranslate(clipboard)
} Else {
r:= GoogleTranslate(clipboard,, "ja") ;DOES WORK
}
} else Return
ToolTip % r.3 "`n`n" r.4
Return
F2:: ToolTip % r.3 "`n`n" r.4
~Esc:: ToolTip
GoogleTranslate(str, from := "auto", to := "en") { ;function by RRR based on teadrinkers GoogleTranslate()
static JS := CreateScriptObj(), _ := JS.( GetJScript() ) := JS.("delete ActiveXObject; delete GetObject;")
json := SendRequest(JS, str, to, from, proxy := "")
oJSON := JS.( "(" json ")" )
step1:= oJSON[0][0][8][0][0][1], step2:= oJSON[0][0][8][1][0][1]
int:= (step1? "1: " step1: "") (step2? " 2: " step2: "")
loop, % lln:=oJSON[8][0].length
lng1.= oJSON[8][0][A_Index-1] (A_Index<lln? ", ": "")
loop, % lln:=oJSON[8][0].length
lng2.= oJSON[8][3][A_Index-1] (A_Index<lln? ", ": "")
lng := "a: " (ls:=oJSON[2]) " b: " lng1 " c: " lng2
Src.= Str ((Pr1:= ojson[0][1][3])? "`n[" Pr1 "]": "")
Dym:= ojson[7][1]
¬ ((Tof:= ojson[7][5])=0)? Src.= (Dym? "`n ►Did you mean: ▌" Dym "?": "")
: (Tof=-1)? Src.= (Dym? "`n ►Showing result for ▌" Dym "`n ►Translate instead ▌" Str: ""): ""
Loop % lln:= oJSON[0].length
mTr .= oJSON[0][A_Index-1][0] (A_Index<lln? "": ((Pr2:= ojson[0][1][2])? "`n[" Pr2 "]": ""))
Main:= Src "`n----------------------`n" mTr
loop, % ojson[1].length
{
trn.= "♦ " ojson[1][cW:=A_Index-1][0] "`n"
Loop, % ojson[1][cW][2].length
{
Loop, % ln:=ojson[1][cW][2][tW:=A_Index-1][1].length
tr.= ojson[1][cW][2][tW][1][A_Index-1] (A_Index<ln? ", ": "")
;. (Mod(A_Index, 5)=0&&A_Index<ln? "`n ": "")
trn.= " ▪ " ((ar:=ojson[1][cW][2][A_Index-1][4])? ar " ": "")
. ojson[1][cW][2][A_Index-1][0] " ► " tr "`n", tr:= ""
}
;} trn:= (trn? "▬ Translations of ►" oJSON[1][0][3] "◄`n" RTrim(trn, "`n"): "")
} trn:= (trn? "▬ Translations of ▌" oJSON[1][0][3] "`n" RTrim(trn, "`n"): "")
loop, % ojson[11].length
{
syn.= "♦ " ojson[11][cW:=A_Index-1][0] " ▌" ojson[11][cW][2] "`n"
Loop, % ojson[11][cw].length
Loop, % ojson[11][cW][cN:=A_Index].length
Loop, % ojson[11][cW][cN][sW:=A_Index-1].length
Loop, % ln:=ojson[11][cW][cN][sW][tW:=A_Index-1].length
syn.= (A_Index=1? " ▪ ": "") ojson[11][cW][cN][sW][tW][A_Index-1] (A_Index<ln? ", ": "`n")
} syn:= (syn? "▬ Synonims`n" RTrim(syn, "`n"): "")
loop, % ojson[12].length
{
def.= "♦ " ojson[12][cW:=A_Index-1][0] " ▌" ojson[12][cW][2] "`n"
loop, % ojson[12][cW][1].length
qu:= ojson[12][0][1][A_Index-1][2]
, def.= " ▪ " ojson[12][cW][1][A_Index-1][0] (qu? "`n """ qu """" "`n": "`n")
} def:= (def? "▬ Definitions`n" RTrim(def, "`n "): "")
loop, % ln:=ojson[13][0].length
exp.= " ♦ " ojson[13][0][A_Index-1][0] (A_Index<ln? "`n": "")
exp:= (exp? "▬ Examples`n" StrReplace(StrReplace(exp, "<b>", "▌"), "</b>"): "")
Return [int, lng, Main, trn, syn, def, exp, Str, ls, mTr]
}
SendRequest(JS, str, tl, sl, proxy) { ; by malcev
static http
ComObjError(false)
loop
{
if !http
{
http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
¬:= ( proxy && http.SetProxy(2, proxy) )
http.open( "get", "https://translate.google.com", 1 )
http.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
http.send()
http.WaitForResponse(-1)
}
http.open( "POST", "https://translate.google.com/translate_a/single?client=webapp&sl="
. sl . "&tl=" . tl . "&hl=en" ;. tl ; &hl=en by RRR
. "&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)
if !InStr(http.responsetext, "<form id=""captcha-form""")
break
http := ""
Sleep, 300 ; by RRR
}
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 doc
doc := ComObjCreate("htmlfile")
doc.write("<meta http-equiv='X-UA-Compatible' content='IE=9'>")
Return ObjBindMethod(doc.parentWindow, "eval")
}
@garry: I merged the two scripts, improved consecutive speech, added history counter, added Gui to select/swap languages, reduced global hotkeys to 2, added expand/shrink history... But have no time and will currently to write instructions... It's now still a bit more an "overkill"! Let's make a deal! I publish the code, and you write the instructions (all hotkeys have all comments)?
Last edited by rommmcek on 30 Jul 2020, 03:38, edited 6 times in total.
-
- Posts: 46
- Joined: 07 May 2020, 07:02
Re: Using Google Translate to automate text translation
@rommmcek Thank you. Thank you! I would really LOVE TO LEARN how to do something like this, but all the guides for like COM and AHK seem to be at least 9 years old +... I was wondering if you could give some tips on what I would need to look into to learning to do stuff like this? Looking at the code I can work out there is JavaScript, Arrays and COM included, but not sure how to study any of those in AHK.. The script works well though, I just need to put some conditions to stop it from showing stuff that is not just basic text now.
@rommmcek Just 1 last question/request, sorry for the double posting! I was wondering if if its possible to output it like this? I tried looking at your code and realise it has something to do with the r variable and its array positions 1 and 3, but was not sure how I could use that information to then do it myself sorry.
[Mod edit: Image fixed.]
@rommmcek Just 1 last question/request, sorry for the double posting! I was wondering if if its possible to output it like this? I tried looking at your code and realise it has something to do with the r variable and its array positions 1 and 3, but was not sure how I could use that information to then do it myself sorry.
[Mod edit: Image fixed.]
Re: Using Google Translate to automate text translation
The image you posted is not visible/downloadable! Can you edit it? O.k. I see it now
As for your question about learning, I'm probably not the right address. I don't know neither Java nor Json and very little COM including the terminology.
What I've done is: MsgBox % json := SendRequest(JS, str, to, from, proxy := "") in the first line after static variable declaration of the GoogleTranslate() function to see the data.
json is then converted to oJSON array (not Ahk array, but w/ similar syntax) from where the data is then being extracted and returned (in my case) with an Ahk array. Unfortunately as an amateur I did some conglomeration of data (Main) in the function...
As for your question about learning, I'm probably not the right address. I don't know neither Java nor Json and very little COM including the terminology.
What I've done is: MsgBox % json := SendRequest(JS, str, to, from, proxy := "") in the first line after static variable declaration of the GoogleTranslate() function to see the data.
json is then converted to oJSON array (not Ahk array, but w/ similar syntax) from where the data is then being extracted and returned (in my case) with an Ahk array. Unfortunately as an amateur I did some conglomeration of data (Main) in the function...
Last edited by rommmcek on 30 Jul 2020, 11:16, edited 1 time in total.
Re: Using Google Translate to automate text translation
O.k. json is:
[Edit]: O.k. I edited the script above (in my previous post). Please test it!
[Edit 2]: Fixed some quirk. Please test it again! [Edit 3]: Done (unfunctional) edit.
Spoiler
And Eigo has one index less then ˈiNG(ɡ)liSH. Can you do it now alone?[Edit]: O.k. I edited the script above (in my previous post). Please test it!
[Edit 2]: Fixed some quirk. Please test it again! [Edit 3]: Done (unfunctional) edit.
Last edited by rommmcek on 30 Jul 2020, 02:26, edited 1 time in total.
-
- Posts: 46
- Joined: 07 May 2020, 07:02
Re: Using Google Translate to automate text translation
@rommmcek Unfortunately I cannot. I just lack the knowledge at this point. As you said it had one less index I thought maybe it would be r.2 but that did not work, neither did r.1. Am I totally heading in the wrong direction? Or is there something more I need to look at?
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: robodesign and 79 guests