Search the Community
Showing results for tags 'setvalue'.
-
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:
-
I use IE in for next loop to set value in INPUT and search something on the web when site take me back response then I read what I need and back to home site and again set value .... $oIE_aspnetForm = _IEGetObjById($oIE, "aspnetForm") $oIE_aspnetForm_ctl00_MainContent_txtAdvPesel = _IEFormElementGetObjByName($oIE_aspnetForm, "ctl00$MainContent$txtAdvPesel") ;When I use Consolewrite(isobj($oIE_aspnetForm_ctl00_MainContent_txtAdvPesel) & @CRLF) ;then result is always = 1 ;I Check to be sure that I have taken correct OBJ Consolewrite($oIE_aspnetForm_ctl00_MainContent_txtAdvPesel.name & @CRLF) ;then result is always = ctl00$MainContent$txtAdvPesel ;so why not always but very often ;this function _IEFormElementSetValue($oIE_aspnetForm_ctl00_MainContent_txtAdvPesel, $s_new_value, 1) ; return to me that error I do severals test by adding sleep - do not take any diffrence trying to _IEAction($oIE_aspnetForm_ctl00_MainContent_txtAdvPesel,"click") - before SetValue trying to _IEAction($oIE_aspnetForm_ctl00_MainContent_txtAdvPesel,"focus") - before SetValue Click And Focus give me back that same errors When I start again "For ... to ..." then its can do for example 50 more steps and crash sometimes do only 10 step somtimes 30 steps a