Jump to content

Google Translator isn't able to get text from _IEFormElementSetValue

Recommended Posts


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:

#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, "&nbsp;", " ")
$txt = StringReplace($txt, "_", "")
$txt = StringReplace($txt, "        ", "")
FileWrite (@scriptdir & '\kat_saved.txt', $txt)
Local $sFilePath = @ScriptDir & "\kat_saved.txt"

ProcessClose ( "iexplore.exe")

;********************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)
MouseMove ( 930, 200, 10)
MouseClick ( "Main", 930, 200, 5, 10)
Sleep (10000)
Local $oText=_IEGetObjById($oIE,"gt-res-data")
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))
$FilePath = @ScriptDir & "\Translated.txt"
$arraytostring = _ArrayToString ($lines)
$txt = StringReplace($arraytostring, "1|", "")
$txt = StringReplace($txt, "|", "")
FileWrite ($FilePath, $txt & @CRLF)
;MsgBox ('', 'Done Bro', 'Done Bro')


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By jmp
      I have IETable,
      Get by this code
      $oTable = _IETableGetCollection ($oIE, 1) $aTableData = _IETableWriteToArray ($oTable) Local Const $iArrayNumberOfCols = UBound($aTableData, $UBOUND_COLUMNS) Local Const $iArrayNumberOfRows = UBound($aTableData, $UBOUND_ROWS) Local $aArraySubstringsRow[$iArrayNumberOfCols] ;~ Local $aExtract = _ArrayExtract ($aTableData, 1, 1, 1, -1) ;~ MsgBox(0, "", $iArrayNumberOfCols) ;~ _ArrayDisplay($aExtract) Local Const $iArrayRowIndex = 1 Local $sSubstring For $i = 0 To $iArrayNumberOfCols - 1     $sSubstring = StringLeft($aTableData[$iArrayRowIndex][$i], 2)     $aArraySubstringsRow[$i] = $sSubstring Next _ArrayDisplay($aArraySubstringsRow, "This is a row") and i want to use cell (52, 82, 18, 9,...10) one by one for selecting dropdown box in internet explorer.

      So, How to show/get/extract cell one by one (in msgbox)? 
    • By Jemboy
      I am trying to create an autologin script for a website we use at work.
      Although the website is public, I  obfuscated the $url deliberately, so it won't show up in public  web searchs. 
      Also username and password are not the working one 😁
      #include <IE.au3> ;$url is delibered obfuscated so it wont be indexed by searchrobots!!! $url = "https://o" & "rdermanager." & "teca" & "llianc" & "e.net/new" & "app/" & "auth/login" $oIE = _IECreate ($url,0,1,1) $HWND = _IEPropertyGet($oIE, "hwnd") WinActivate ($HWND,"") WinSetState($HWND, "", @SW_MAXIMIZE) $oUsername = _IEGetObjById ($oIE,"login-txt-username") $oPassword = _IEGetObjById ($oIE,"login-txt-password") $oButton = _IEGetObjById ($oIE,"changepwd-btn-request") _IEFormElementSetValue ($oUsername, "me@test.com") _IEFormElementSetValue ($oPassword, "Test1234!") _IEAction ($oButton, "click") When running the above code, the fields are populated, however when [Login] button is "clicked" the fields wil show "This field is required".

      Only when I add a charachter manually and remove that character  for each field, the page will update the values internally.
      Could some tell me a way to fix this? The cookie button on the top of the page does not have an ID, so I do not how to click on it from autoit.
      Is there another way to press this button ?
    • By Omnitica
      I'm new to the forums! Couldn't find any threads covering this issue. Sorry if I'm wrong.

      I'm having problems changing the text/value of a input box. The particular box doesn't have a name or id, just: class="jq_hotkeys_enabled form-control".
      This class appears multiple times throughout the source, so I don't think It's right to reference that object. 
      See image 1.
      However, I've managed to find a object with the name "ctl00$content$ctrl$ucServiceTime$rpServicetimes$ctl00$edtHiddenResourceHelper" which contains the value of the input box, and the id for the person in the dropdown/combobox left of it. (with "dummy-1" selected).
      See image 2.
      As you can see the value is 3982,4545     ( name , time )
      But when I try to change the value of it by doing:
      #include <IE.au3> Local $oIE = _IEAttach(WinGetHandle("[CLASS:IEFrame]"),"embedded") Local $oForm = _IEFormGetObjByName($oIE, "aspnetForm") Local $oInput = _IEFormElementGetObjByName($oForm, "ctl00$content$ctrl$ucServiceTime$rpServicetimes$ctl00$edtHiddenResourceHelper") _IEFormElementSetValue($oInput, "3982,1337") The box doesn't get its new value. I  can see in the source that it's changed though.
      See image 3.
      However, if I do: 
      #include <IE.au3> Local $oIE = _IEAttach(WinGetHandle("[CLASS:IEFrame]"),"embedded") Local $oForm = _IEFormGetObjByName($oIE, "aspnetForm") Local $oInput = _IEFormElementGetObjByName($oForm, "ctl00$content$ctrl$ucServiceTime$rpServicetimes$ctl00$edtHiddenResourceHelper") _IEFormElementSetValue($oInput, "3982,1337") $oIE.document.parentwindow.execScript("theForm.submit()") ; But it needs to reload the page The box gets its new value after the page reloads by the theForm.submit() function. 
      This is a bit unfortunate as I want the changes to happen instantly like when I type in the box with the keyboard... or select in the combobox.
      Maybe someone knows how I can do this? Looking forward to an answer! 
      Thanks in advance.
      Note: Unfortunately I can't provide with the real URL as it is constricted to employees in the company I work for, but let me know If I should provide anything else.

    • By talkfoodtalk
      HI,   I cannot work out how to connect to the input box on this link:   https://cms.bskyb.2wire.com/manage/login   My usual method is in my code but it does not seem to find the elements I need to connect with. I can see that "text" and "password" are on the page but im confused about putting input to it.   Can someone point me in the right direction?         Kind Regards Dave #include <IE.au3> #include <MsgBoxConstants.au3> $PACE = _IEAttach("https://cms.bskyb.2wire.com/manage/login", "url") If @error Then MsgBox($MB_SYSTEMMODAL, "Error", "PACE not attached") $PACE =_IECreate("https://cms.bskyb.2wire.com/manage/login") EndIf $colForms = _IEFormGetCollection ($PACE ) For $oForm In $colForms $colElements = _IETagNameAllGetCollection ( $oForm ) For $oElement In $colElements If StringInStr ( $oElement.getAttribute ( "tkPid", 2 ), "PID19" ) <> 0 Then MsgBox(0, "Result", "Success") _IEFormElementSetValue($oElement, "username") ;~ _IEAction ( $oElement, "click" ) Else EndIf If StringInStr ( $oElement.getAttribute ( "__eventBits=", 2 ), "7409" ) <> 0 Then MsgBox(0, "Result", "Success") _IEFormElementSetValue($oElement, "password") ;~ _IEAction ( $oElement, "click" ) Else EndIf Next Next Local $oInputs = _IETagNameGetCollection($PACE, "input") Local $sTxt = "" For $oInput In $oInputs $sTxt &= $oInput.type & @CRLF if $oInput.type = "text" Then EndIf Next MsgBox($MB_SYSTEMMODAL, "Form Inqput Type", "Form: " & $oInput.form.name & @CRLF & @CRLF & " Types :" & @CRLF & $sTxt)    
    • By kalel69
      Hi Folks.  Looking for a little assistance to help login to one of my company's application's web pages.  These are Intranet based pages, and not open to the general public, and I will try to provide the code and screen shots where I can.  I have been attempting to get this login script to work for quite some time.  Any help would be appreciated. 
      I have 3 types of issues here.
      1.  using the basic _IEFormElementSetValue, instead of replacing the grayed out verbiage (user name) with an un-grayed out text (actual user name in black type font), it does enter the user name, but it is entered still as grayed out text in the input box.
      2.  to get the above to work, i've replaced using _IEFormElementSetValue and instead use an "_IEAction" (2 actually - focus / select all) then a "send" to manually put in the username.  This works upon initial launch of the page, but when logged out, and logging back in, the IEactiion and send fail to enter the fields.
      3.  My company has an .hta application that launches a reporting app, but the page is designed exactly the same as the web page, (except the app contains the code - the .hta app), but it is still the exact same fields defined.  Theoretically knowing the input boxes names as I do and that they're the same, I should be able to log into this app the same way.  However, I can not.  I once contacted dale through email to question why the .hta app would not respond, and he gave me some ideas, and stated if I still have issues, to post a topic here.  so this is what I'm doing, because I still have issues with the .hta app.  And I've also tried to attach to the .hta application as an embedded application, but still could not get the fields to populate (log in screen).
      I have attached screen shots of the intial view of the sign on page, and the view of an attempted signon using _IEFormElementSetValue.
      Here is my code to attempt to attach / launch-create the web page.
      Func _LaunchAdminApp () If $CurServNam= "" Then Return If WinExists("PCDS :: Management") Then Return Local $FTMAddress= "https://"&$CurServNam&"/admin" If NOT WinExists("Fluency for Imaging Log On") Then Local $oIE = _IECreate($FTMAddress) Else Local $oIEWhnd = WinGetHandle("Fluency for Imaging Log On") Local $oIE = _IEAttach($oIEWhnd) EndIf Local $Count = 0 If $AdmAutoLogin = 1 Then If $LoginIDAA = "" Then Return Do $Count+=1 Sleep(100) If $Count > 30 Then MsgBox(0,"Sorry","Can't sign in to Admin App!") Return EndIf Until IsObj($oIE) Local $oForm = _IEFormGetCollection($oIE,0) $Count = 0 Do $Count+=1 Sleep(100) If $Count > 30 Then MsgBox(0,"Sorry","Can't sign in to Admin App!")5 Return EndIf Until IsObj($oForm) WinActivate($oIE) Local $oQueryUser= _IEFormElementGetObjByName ($oForm, "UserName" ) Local $oQueryPW = _IEFormElementGetObjByName ($oForm, "PasswordDisplay") Local $CompID = _IEFormElementGetObjByName ($oForm, "Domain" ) Local $oSubmit = _IEFormElementGetObjByName ($oForm, "loginBtn" ) Sleep(500) ;_IEAction ($oQueryUser,"focus" ) ;_IEAction ($oQueryUser,"selectall" ) ; Send ($LoginIDAA );this will work only for initial login, not for subsequent log in's after logoff. _IEFormElementSetValue ($oQueryUser, $LoginIDAA );this does not work. enters name in gray text, app does not think its there, but can see it. ;_IEAction ($oQueryPW, "focus" ) ;_IEAction ($oQueryPW, "selectall" ) ; Send ($PasswordAA );this will work only for initial login, not for subsequent log in's after logoff. _IEFormElementSetValue ($oQueryPW, $PasswordAA );this does not work. enters password in gray text, app does not think its there, but can see it. _IEFormElementOptionSelect ($CompID,0,1,"byIndex" ) Sleep(5000) If IsObj($oSubmit) Then $oSubmit.click() EndIf If $CloseAfSelAA = 1 Then Exit EndFunc Basically, i'm checking to see if the pages exists first, then either creating a page or attaching to a page depending upon the results of the check.
      I've also attached the source for the signon page for the web app.  Note that the code delivered via the .hta for sign on is exactly the same.
      any and all suggestions are most welcome.  I'm at my witts end here! 
      Thanks in advance!  (I love AutoIT! and this site!)
      view of signon screens.zip
      Company Application Signon Page.html
  • Create New...