Jump to content

Recommended Posts

Hello guys!

I have a problem with a script, in the past I made a program and it worked perfect, I recently used it again and it already stands still in one step, the problem is a Javascript event that changed but now I cannot execute it.

 

<td colspan="2" align="center"><input type="button" id="Buscar" name="Buscar" value="Buscar" onclick="javascript:enviarForma(document.obtenercasosPersonaPorDocumento,'0');" class="boton"></td>

 

Previously I used this code and it worked, but now it does nothing

$botonconsulta = _IEGetObjByName($oIE,"Buscar")
 _IEAction($botonconsulta, 'click')
 _IELoadWait($oIE)

 

Now I have tried the following codes but none works.

 

;==================== 1
_IEHeadInsertEventScript($oIE, "document", "onclick", "javascript:enviarForma(document.obtenercasosPersonaPorDocumento,'0');")
ControlClick("SUPER CELAC", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]")
_IELoadWait($oIE)

;==================== 2
$forma = $oIE.document.obtenercasosPersonaPorDocumento
$oIE.Navigate("JavaScript:enviarForma("&$forma&",""0"");")
_IELoadWait($oIE)

;==================== 3
$boton = _IEGetObjById($oIE, "Buscar")
$boton.document.parentwindow.execScript("enviarForma(document.obtenercasosPersonaPorDocumento,'0');", "javascript")

I hope you can guide me, because I think the error is in the parameters that the javascript function receives but I don't know how to send it, here I leave the first part of the JavaScript function.

function enviarForma(frm,tipoForma){
  
    var bExisteDatoConsulta = false;  
    var bError=true;
    var mensajeError="";
    

    switch (tipoForma) {
        //--Forma documento
        case "0":
            if (validar_campo_no_vacio_no_print(frm.numeroDocumento)) {
                if (!isNum(frm.numeroDocumento.value)) {
                    bError = false;
                    mensajeError += "El número de documento debe ser un valor numérico\n";
                }
                bExisteDatoConsulta = true;
            } else {
                mensajeError += "Debe digitar un número de documento\n";
            }

            break;

 Thanks!

Share this post


Link to post
Share on other sites
21 minutes ago, JuanFelipe said:

Previously I used this code and it worked, but now it does nothing

$botonconsulta = _IEGetObjByName($oIE,"Buscar")
 _IEAction($botonconsulta, 'click')
 _IELoadWait($oIE)

Is there any information written to the Output panel when you run this code in Scite?

You could also try this variation --

$botonconsulta = _IEGetObjByName($oIE,"Buscar")
$hWnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($botonconsulta, "focus")
ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

 

Share this post


Link to post
Share on other sites
32 minutes ago, Danp2 said:

 

$botonconsulta = _IEGetObjByName($oIE,"Buscar")
$hWnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($botonconsulta, "focus")
ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

 

In an input of the page I write a value automatically.

I tried the code you shared with me and it throws this error:

 

"D:\windows\install\Include\IE.au3" (2168) : ==> The requested action with this object has failed.:
Return SetError($_IESTATUS_Success, 0, HWnd($oObject.HWnd()))
Return SetError($_IESTATUS_Success, 0, HWnd($oObject^ ERROR
>Exit code: 1    Time: 46.2

 

Share this post


Link to post
Share on other sites

I did it like this:

 

$botonconsulta = _IEGetObjByName($oIE,"Buscar")
;~          $hWnd = _IEPropertyGet($oIE, "hwnd")
            _IEAction($botonconsulta, "focus")
            ControlSend("SUPER CELAC", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
            _IELoadWait($oIE)

and it puts the focus on the button, it does enter and I can click but the page does not respond, it is as if it did not execute the function.

Share this post


Link to post
Share on other sites
6 minutes ago, Danp2 said:

Instead of this --

_IEAction($botonconsulta, 'click')

have you tried this?

$botonconsulta.click()

If that doesn't work, can you share the URL for the website so that we can take a look?

Yes, I tried all that, I can't share the URL since it's my company's intranet, so it won't work. I have a webbroser open in the GUI and I click it manually and it does nothing, but if I open everything from any browser it works normal, that's why I thought about executing the javascript function alone, I really don't know which way to go.

Share this post


Link to post
Share on other sites
6 minutes ago, JuanFelipe said:

I have a webbroser open in the GUI a

Wait... so you are using an embedded browser? If so, you should have mentioned that in your initial post. 🙄

Suggest that you find the previous thread discussing modification of IE version for IE embedded browser.

Share this post


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 DirtyJohny
      Hi everyone.Need rewrite this function how in еxample.
      Original:
      #RequireAdmin #NoTrayIcon Opt("MustDeclareVars",1) Func _a() Local $sls=ObjGet("winmgmts:{impersonationLevel=impersonate," _ &"authenticationLevel=Pkt}!\\"& _ @ComputerName&'\root\wmi'),$lss=$sls.ExecQuery _ ('SELECT * FROM WmiMonitorID'), _ $lll,$sll,$sss="",$lsl,$lls,$i,$z For $z In $lss $lsl=$z.UserFriendlyName For $i=0 To Ubound($lsl)-1 if ($lsl[$i]) Then $lll&=Chr($lsl[$i]) Next $lls=$z.SerialNumberID For $i=0 To Ubound($lls)-1 if ($lls[$i]) Then $sll&=Chr($lls[$i]) Next $sss&="Model"&@TAB&@TAB&": "&$lll&@CR&"Serial Number"&@TAB&": "&$sll&@CR&@CR $lll="" $sll="" Next MsgBox(262144,'Monitors '&$lss.Count,$sss&" "&@CR) $lss=Null $sls=Null EndFunc _a() Example:
      Func _InfoPC() Local $ObjService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & @ComputerName & '\root\cimv2') Local $ObjMB = $ObjService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0x30) If IsObj($ObjService) Then For $objItemMB In $ObjMB $sInfo &= @TAB & 'Motherboard: ...... ' & $objItemMB.Product & @CRLF I'm beginner in this sphere and need  you all speak easy and simply because i'm Russian.Thanks)
    • By Deshanur
      Am trying to automate injecting credential on the login form for all kind of Web application for IE. I know how to identify the form name by viewing the source code and using the method - _IEFormGetObjByName($ie, $form_Name).
      I would like to know how to identify or get the form object for the web app where there is no form name tag for example below, for the is I have used - _IEFormGetCollection($ie, 0) to get the form object.
      My Question is does it work for all kind of application "_IEFormGetCollection($ie, 0)" how to identify Index value? is it always 0? is there any better solution?
      The final solution am looking for is find out form object, get the username, password field and inject credential and submit the form.
      How to find out index value? for the forms which does not have form name field.
      $login_form = _IEFormGetCollection($ie, 0) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}") OR This works fine if the form has form name. $login_form = _IEFormGetObjByName($ie, $form_Name) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}")
    • By Gowrisankar
      Dear members of the forum,
      I'm working on a project in which I have to use Image recognition technique. 
      Due to client restrictions, I couldn't use AutoIt for this project. 
      Is there a way to use this DLL "ImageSearchDLL.dll" (which is used to do image recognition steps in AutoIt) in VB.Net to achieve the same result? 
      I have used this DLL few years before and got good results. If there is a latest version of this DLL and if you can share it, that will be helpful too.
      Any guidance is deeply appreciated.
    • By learner123
      Hi All,
       
      I am new to this AUTO IT and I have created a script that will open an app,enter pin and copy the code generated to clipboard. My java code call this autoIT script and use the copied generated code from clipboard.
      This works fine when server  window is on focus. My server is an windows server. 
      But when I minimize or disconnect the server, the script opens the app.exe but doesn't copy any value to clipboard.  
      Can anyone help me on this 😐
       
      Run("C:\Program Files (x86)\RSA SecurID Software Token\SecurID.exe")
      Local $hWnd=WinWait("abc - RSA SecurID Token") ; waits until the window is the active window
      $hWin = WinGetHandle("abc - RSA SecurID Token");
      ControlSend($hWnd,"","","1111") ; simulates pressing the Home key
      ControlSend($hWnd,"","","{ENTER}");
      ControlSend($hWnd,"","","^c");
      Sleep(1000) ;
      ControlSend($hWnd,"","","^c");
       
×
×
  • Create New...