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')


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]")

;==================== 2
$forma = $oIE.document.obtenercasosPersonaPorDocumento

;==================== 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";



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')

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}")


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


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}")

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.

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

Instead of this --

_IEAction($botonconsulta, 'click')

have you tried this?


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.

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 Zaoka
      for couple of years I'm using  Jos script for sending reports, email with excel attachment. But from last week i'm getting this error when sending excel or word attachment
      message has lines too long for transport jpeg, pdf works with no problems, any sugestion ?
    • By diepfeile
      I'm using the following:
      newly installed Beta
      SQlite version 3380000 aka 3.38.0
      I put sqlite3.dll and sqlite3_x64.dll in C:\Windows\System32 since many scripts depend on them.

      I extended the output of _SQLite_Startup()
      ConsoleWrite("@AutoItX64 " & @AutoItX64 & @CRLF) ConsoleWrite("$sDll_Filename " & $sDll_Filename & @CRLF) ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)

      Also using the script from https://www.autoitscript.com/autoit3/docs/libfunctions/_SQLite_Startup.htm for testing.

      >Running:(\Program Files (x86)\AutoIt3\autoit3.exe "R:\Download\aasdf.au3" @AutoItX64 0 $sDll_Filename sqlite3.dll _SQLite_LibVersion=0 >Running:(\Program Files (x86)\AutoIt3\autoit3_x64.exe "R:\Download\aasdf.au3" @AutoItX64 1 $sDll_Filename sqlite3_x64.dll _SQLite_LibVersion=3.38.0 >Running:(\Program Files (x86)\AutoIt3\Beta\autoit3.exe "R:\Download\aasdf.au3" @AutoItX64 0 $sDll_Filename sqlite3.dll _SQLite_LibVersion=0 >Running:(\Program Files (x86)\AutoIt3\Beta\autoit3_x64.exe "R:\Download\aasdf.au3" @AutoItX64 1 $sDll_Filename sqlite3_x64.dll _SQLite_LibVersion=3.38.0

      Why doesn't it work in 32bit, despite me having the 32bit sqlite.dll? Autoit urges running scripts in 32bit mode and Scite starts scripts just in 32bit mode without the flag?
      With #AutoIt3Wrapper_UseX64=Y it just works, both normal Autoit and beta!
      sqlite3.dll sqlite3_x64.dll
    • By Iraj
      Hello Team, Greetings!
      Is there any way to run any 3rd party application silently in background without the GUI getting in the front ?
      I was implementing angry-ip scanner with autoit & wanted the angry-ip application to run in background quietly as I am copying its output to other file on completion. is there any way to achieve my query?
      Below is code I tried: 
      $range = "" ShellExecuteWait("C:\Windows\DDM\ipscan.exe","-f:range "&$iprange&" -q -o C:\temp\ScanResults.csv","","open",@SW_HIDE) Thanks!
    • By PeterVerbeek
      This topic give you access to an AutoIt functions library I maintain which is called PAL, Peter's AutoIt Library. The latest version 1.26 contains 214 functions divided into these topics:
      window, desktop and monitor GUI, mouse and color GUI controls including graphical buttons (jpg, png) logics and mathematics include constants string, xml string and file string dialogues and progress bars data lists: lists, stacks, shift registers and key maps (a.ka. dictionaries) miscellaneous: logging/debugging, process and system info Change log and files section  on the PAL website (SourceForge).
      A lot of these functions were created in the development of Peace, Peter's Equalizer APO Configuration Extension, which is a user interface for the system-wide audio driver called Equalizer APO.
    • By Hermes
      Hi, I am struggling in setting the value of a textarea based on the value of clipboard (that contains a long web page source codes). If I use _WD_SetElementValue, it freezes after some time, or appears to be pressing tab and goes out of focus. I can also use send keys but i need the script to run in the background.
      Here is the full script:
      #Include "Chrome.au3" #Include "wd_core.au3" #Include "wd_helper.au3" #Include "WinHttp.au3" #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <AutoItConstants.au3> #include <WinAPIFiles.au3> #include <GDIPlus.au3> #include <Excel.au3> Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_LoadWait($sSession) _WD_Navigate($sSession, "http://demo.borland.com/testsite/stadyn_largepagewithimages.html") _WD_LoadWait($sSession) Global $sSource = _WD_GetSource($sSession) Local $Paste = ClipPut($sSource) Local $sData = ClipGet() Local $aArray = 0, _ $iOffset = 1 While 1 $aArray = StringRegExp($sData, '(?s)<p>.*</p>', $STR_REGEXPARRAYMATCH, $iOffset) If @error Then ExitLoop $iOffset = @extended For $i = 0 To UBound($aArray) - 1 Local $Paste = ClipPut($aArray[$i]) Local $sRegExData = ClipGet() ;MsgBox(0, "", "$sRegExData = " & $sRegExData) Next WEnd _WD_Navigate($sSession, "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_textarea_placeholder") _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "iframe#iframeResult") Local $sElement1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "iframe#iframeResult") _WD_FrameEnter($sSession, $sElement1) _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/textarea") $textarea = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/textarea") _WD_ElementAction($sSession, $textarea, 'click') ;WD SetElementValue(SsSession, Stextarea, $sRegExData) <-- I can do this but the focus goes out, or the browser freezes _WD_FrameLeave($sSession) sleep(2000) Send("^v") _WD_LoadWait($sSession) _WD_Shutdown() Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}' EndFunc ;==>SetupChrome Can someone help me please, or re-direct me to the right path? TIA!
  • Create New...