I used to have a script that worked to retrieve information from the Target section of the DeepL translator. It went like this:
Code: Select all
IE := ComObjCreate("InternetExplorer.Application") ;~ Creation of hidden Internet Explorer instance to look up Deepl Translate and retrieve translation
IE.Visible := false
IE.Navigate(Path) ; Path is the URL which includes the information that needs to be translated
While IE.readyState!=4 || IE.document.readyState!="complete" || IE.busy ; Wait until page is loaded?
Sleep 50
While (IE.document.getElementsByTagName("textarea")[1].value = "") ;Since the conversion takes a second we want to wait till the value is filled otherwise the return will always be nothing
{
Sleep 50
If (A_Index >190) { ; Taking too long
; MsgBox ,,,Error`, starting, .5
IE.Quit
Return Result:="Translation failed"
}
}
Result := IE.document.getElementsByTagName("textarea")[1].value; THIS IS THE RESULT I WANT!
I tried something like this, checking information about Rufaydium, but firstly I am only able to open a Chrome instance instead of an MS Edge one, and secondly I am not able to do anything with it. Very pathetic I know.
Code: Select all
ChromeDriver := A_ScriptDir "\chromedriver.exe"
; choose different driver in order to automate different Browser
; Driver := new RunDriver("ChromeDriver.exe") ; running driver
Driver := new RunDriver("ChromeDriver.exe")
Chrome := new Rufaydium(Driver) ; this will return control over Browser
; choosing Browser Capabilities, by using Capabilities Class you can make custom profile for specific need
; Chrome.capabilities := Capabilities.ChromeDefault
; this is how we create session
Page := Chrome.NewSession()
Page.Visible := false
Page.Navigate(Path)
While Page.readyState!=4 || Page.document.readyState!="complete" || Page.busy ; Wait until page is loaded?
Sleep 50
While (Page.document.getElementsByTagName("textarea")[1].value = "") ;Since the conversion takes a second we want to wait till the value is filled otherwise the return will always be nothing
{
Sleep 50
If (A_Index >190) { ; Translation taking too long
; MsgBox ,,,Error`, restarting, .5
Page.Quit
Return Result:="Translation failed"
}
}
Result := Page.document.getElementsByTagName("textarea")[1].value ;