Search the Community
Showing results for tags 'google translation'.
-
Hi, Google changed the style of translation page therefore _IEFormElementSetValue stopped working to set values in the google translator page automatically, I tried my best to fix it but it's not happening. It was working perfect a month ago almost before launching of new google translation interface. Any help would be highly appreciated... I'm using a kind of function that help to set values in the form to google translator page and let it translate and then retrieve it back to save in a text file. Here is my code: #RequireAdmin #include <IE.au3> #include <String.au3> #include <Array.au3> #include <Excel.au3> #include <File.au3> ;*****************************Splitting Source Code Ended***************************** Local $oExcel = _Excel_Open() Local $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\example.xlsx", False) ;*****************************Saving Software Links Started*************************** ;*****************************Splitting Source Code Started***************************** ;***************************************** Saving Title + .rar link + Description text file No. 1***************************** ProcessClose ( "iexplore.exe") $file = fileopen(@ScriptDir & "\source.txt", 10) $splitting = _Excel_RangeRead ($oWorkbook1, Default, "A1") $IE = _IECreate($splitting, 0, 0) $source = _IEDocReadHTML($IE) FileWrite($file, $source) $target_source5 = _StringBetween($source, '</h1>', '<i>Скачать</i>') If Not @error Then FileWrite (@ScriptDir & "\kat01.txt", $target_source5[0]) Sleep (50) ; removing of HTML codes to convert data into simple text $File1 = @ScriptDir & "\kat01.txt" $txt = FileRead($File1) $txt = StringReplace($txt, "<br>", @crlf) $txt = StringRegExpReplace($txt, '(?s)<a.*?</a>|<.*?>', "") $txt = StringStripWS ( $txt, $STR_STRIPSPACES) $txt = StringReplace($txt, "<br><", "") $txt = StringReplace($txt, "--", "") $txt = StringReplace($txt, "---", "") $txt = StringReplace($txt, " ", " ") $txt = StringReplace($txt, "_", "") $txt = StringReplace($txt, " ", "") FileWrite (@scriptdir & '\kat_saved.txt', $txt) Local $sFilePath = @ScriptDir & "\kat_saved.txt" ProcessClose ( "iexplore.exe") Example1() EndIf ;********************Example1 Function Written Started***************************** Func Example1() $Text = FileRead ($sFilePath) Local $aArray = StringSplit($Text, @CR) For $i = 1 To $aArray[0] Local $tag="* *" Local $oIE=_IECreate("https://translate.google.com/#ru/en", 1, 1) $HWND = _IEPropertyGet($oIE, "hwnd") WinSetState($HWND, "", @SW_MAXIMIZE) Sleep (500) Local $oForm=_IEFormGetCollection($oIE,0) Local $oQuery=_IEGetObjByName($oForm,"text") _IEFormElementSetValue($oQuery, $tag & @CR & $aArray[$i] & @CR & $tag) MouseMove ( 930, 275, 10) MouseClick ( "Main", 930, 275, 5, 10) Sleep(1000) MouseMove ( 930, 200, 10) MouseClick ( "Main", 930, 200, 5, 10) Sleep (10000) _IELoadWait($oIE) Local $oText=_IEGetObjById($oIE,"gt-res-data") $lines=StringSplit(_IEPropertyGet($oText,"innerText"),@CRLF,1) _IEQuit($oIE) ProcessClose ( "iexplore.exe") Sleep (1000) _ArrayDelete($lines,_ArraySearch($lines,$tag,1,0,0,1,0) & "-" & $lines[0]) _ArrayDelete($lines,"1-" & _ArraySearch($lines,$tag,1,0,0,1,1)) $lines[0]=UBound($lines)-1 $FilePath = @ScriptDir & "\Translated.txt" $arraytostring = _ArrayToString ($lines) $txt = StringReplace($arraytostring, "1|", "") $txt = StringReplace($txt, "|", "") FileWrite ($FilePath, $txt & @CRLF) Next EndFunc ;MsgBox ('', 'Done Bro', 'Done Bro')
-
- _ieformelementsetvalue
- google translation
-
(and 2 more)
Tagged with: