I am a translator. I have found that DeepL is an online translator that translates much much better than the crap translation my agency provides me with to perform a Machine Translation Edit. I work with a Translation Tool called Trados.
So I had the following idea. It would be great to have a script to do the following.
1. Copy source text (text to translate).
2.- Paste it onto the Source Language box in deepl.com/translate.
3.- Collect the translated text from the target language box.
4.- Paste that text in the relevant target location in my translation tool.
5.- Advance to the next line/segment of text. Do so a certain number of steps.
My script does precisely that, but in a crappy and newbie way. it just uses SendInputs, MouseMove, Clicks and Winactivates (Trados<->Firefox) to do the job. It does it, but barely. Since my scripting skills are close to zero, I have filled the script with Sleeps to help minimize any random behaviour, copy pasting not working, and the like. It is slow, I have to keep the monitors on since the mouse is moving back and forth, and it looks awfully slow, but that is more or less my scripting skills. Out of shame, I am NOT posting it... it's THAT lame.
However, I found a guy who did a similar script for Google Translate, but worked differently in the sense that, when the script opened Internet Explorer to load the Google Translate page, it did it in a hidden from view way, so it was much better looking. And apparently, instead of taking the mouse to a certain point in the website page, clicking, sending Control A and then Control X, it apparently had a way of "reading" the contents of the target language box directly, with some kind of DOM object. I have not an inkling of what DOM objects do or are, I just search for them in the Internet. But I believe they are things such as all obscure functions starting with IE.
If anyone has any inkling of what I am talking about and could adapt this code to work with DeepL, I would be extremely helpful. I am not posting my own script (the one that goes back and forth with the mouse) because it's too pitiful, but here's is the script of the guy that works with Google Translate.
Code: Select all
#NoEnv ;~ Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ;~ Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ;~ Ensures a consistent starting directory.
SetTitleMatchMode, 3
LangIn ="en"
LangOut = "es"
;~ [Ctrl]+[F12] shows the little user interface for changing source and target language
^F12::
Gui, 1:Show, Autosize
Return
;~ [F12] runs Google Translate for selected text or makes the tooltip with the translation disappear if it is visible
F12::
CurrentCB = %Clipboard%
Clipboard =
SendInput, ^c
ClipWait, 5
If ErrorLevel
{
MsgBox, 48, GoogleTranslateSelection, No text highlighted or problem copying text to clipboard.
Return
}
Source = %Clipboard%
StringLen, SourceLength, Source
SourceLength := SourceLength * 5
ToolTip, Translating... please wait ☺., % A_CaretX-SourceLength, % A_CaretY+50
Target =
Target := GoogleTranslate(Source,en,es)
ToolTip, %Target%, % A_CaretX-SourceLength, % A_CaretY+50
Clipboard = %Target%
GoogleTranslate(Source,LangIn,LangOut)
{
StringReplace, Source, Source, %A_Space%, `%20, All
Base := "translate.google.com/#"
Path := Base . "en" . "/" . "es" . "/" . Source
IE := ComObjCreate("InternetExplorer.Application") ;~ Creation of hidden Internet Explorer instance to look up Google Translate and retrieve translation
IE.Navigate(Path)
While IE.readyState!=4 || IE.document.readyState!="complete" || IE.busy
Sleep 50
Result := IE.document.all.result_box.innertext
IE.Quit
Return Result
}
Code: Select all
Result := IE.document.all.result_box.innertext
The script is not exactly what I need, but I think what I need would be easily adapted. What I need is to be able to input the source text and obtain the target text from http://www.deepl.com/translator. This script does it from Google Translate... and I am not able to do the change