Jump to content

jQuerify a web page (injecting jQuery)


Gianni
 Share

Recommended Posts

An example on how to inject jQuery into a web page
It can be useful to manage the page from AutoIt using jQuery.
Idea from here: http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet
Suggestions and improvements are welcome

#include <ie.au3>

Example()

Func Example()
    Local $oIE = _IECreate("www.google.com")
    Local $jQuery = _jQuerify($oIE)

    MsgBox(0, "Version", "jQuery version: " & $jQuery.fn.jquery)
    MsgBox(0, "Example", "click ok to exit." & @CRLF & "Google logo will fade out by jQuery...")

    $jQuery('#hplogo').fadeOut(3000) ; jQuery will fade out the google logo
EndFunc   ;==>Example


; #FUNCTION# ====================================================================================================================
; Name ..........: _jQuerify
; Description ...:
; Syntax ........: _jQuerify(Byref $oIE)
; Parameters ....: $oIE                 - Object variable of an InternetExplorer.Application.
; Return values .: an object variable pointing to the jQuery library
; Author ........: Chimp
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _jQuerify(ByRef $oIE)

    Local $jsEval, $jQuery, $otherlib = False

    ; create a reference to the javascript eval() function
    $oIE.document.parentWindow.setTimeout('document.head.eval = eval', 0)
    Do
        Sleep(250)
        $jsEval = Execute('$oIE.Document.head.eval')
    Until IsObj($jsEval)

    ; if jQuery is not already loaded then load it
    If $jsEval("typeof jQuery=='undefined'") Then

        ; check if the '$' (dollar) name is already in use by other library
        If $jsEval("typeof $=='function'") Then $otherlib = True

        Local $oScript = $oIE.document.createElement('script');
        $oScript.type = 'text/javascript'

        ; If you want to load jQuery from a disk file use the following statement
        ; where i.e. jquery-1.9.1.js is the file containing the jQuery source
        ; (or also use a string variable containing the whole jQuery listing)
        ;~ $oScript.TextContent = FileRead(@ScriptDir & "\jquery-1.9.1.js") ; <--- from a file

        ; If you want to download jQuery from the web use this statement
        $oScript.src = 'https://code.jquery.com/jquery-latest.min.js' ; <--- from an url


        $oIE.document.getElementsByTagName('head').item(0).appendChild($oScript)
        Do
            Sleep(250)
        Until $jsEval("typeof jQuery == 'function'")
    EndIf

    Do
        Sleep(250)
        $jQuery = $jsEval("jQuery")
    Until IsObj($jQuery)

    If $otherlib Then $jsEval('jQuery.noConflict();')

    Return $jQuery
EndFunc   ;==>_jQuerify

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Hi @argumentum, thanks for the feedback,

I suppose you has trouble downloading the jQuer library from the link.
try to see if you can download it manually (from the same link or find another one) and save it in the same directory of the script and then modify the AutoIt code by commenting out the line marked with "; <--- from an url" and use the line marked as "; <--- from a file" so to use a jQuery library loaded from the local file instead of from the url. (btw (I don't say for You, but I just say for the record) the file name in the "; <--- from a file" line has to be adjusted accordingly)."
Please let us know what happens .... Thanks.

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Hello,
I've modified a bit the script to chek the IE version and use appropriate commands to get reference to the javascript eval() function. At the moment I've access only to an IE version 11 and I can not test if it works on IE < 11
Could someone please check if this script is working on IE versions lesser than 11.
It should inject jquery (if not already present in the page), show the jquery version (injected or already present) and use jquery to make the google logo disappear from the page (just for a test).
Thanks for the help

#include <ie.au3>

Example()

Func Example()
    Local $oIE = _IECreate("www.google.com")
    Local $jQuery = _jQuerify($oIE)

    MsgBox(0, "Version", "jQuery version: " & $jQuery.fn.jquery)
    MsgBox(0, "Example", "click ok to exit." & @CRLF & "Google logo will fade out by jQuery...")

    $jQuery('#hplogo').fadeOut(3000) ; jQuery will fade out the google logo
EndFunc   ;==>Example


; #FUNCTION# ====================================================================================================================
; Name ..........: _jQuerify
; Description ...:
; Syntax ........: _jQuerify(Byref $oIE)
; Parameters ....: $oIE                 - Object variable of an InternetExplorer.Application.
; Return values .: an object variable pointing to the jQuery library
; Author ........: Chimp
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _jQuerify(ByRef $oIE)

    Local $msie, $jsEval, $jQuery, $otherlib = False

    $msie = Execute('$oIE.document.documentMode')

    If ($msie = "") Or Number($msie) < 11 Then ; an IE version < 11
        ; create a reference to the javascript eval() function
        $oIE.document.parentWindow.setTimeout('window.eval = eval', 0)
        Do
            Sleep(250)
            $jsEval = Execute('$oIE.Document.parentwindow.eval')
        Until IsObj($jsEval)

    Else ; IE version > = 11
        ; create a reference to the javascript eval() function
        $oIE.document.parentWindow.setTimeout('document.head.eval = eval', 0)
        Do
            Sleep(250)
            $jsEval = Execute('$oIE.Document.head.eval')
        Until IsObj($jsEval)

    EndIf

    ; if jQuery is not already loaded then load it
    If $jsEval("typeof jQuery=='undefined'") Then

        ; check if the '$' (dollar) name is already in use by other library
        If $jsEval("typeof $=='function'") Then $otherlib = True

        Local $oScript = $oIE.document.createElement('script');
        $oScript.type = 'text/javascript'

        ; If you want to load jQuery from a disk file use the following statement
        ; where i.e. jquery-1.9.1.js is the file containing the jQuery source
        ; (or also use a string variable containing the whole jQuery listing)
;~ $oScript.TextContent = FileRead(@ScriptDir & "\jquery-1.9.1.js") ; <--- from a file

        ; If you want to download jQuery from the web use this statement
        $oScript.src = 'https://code.jquery.com/jquery-latest.min.js' ; <--- from an url


        $oIE.document.getElementsByTagName('head').item(0).appendChild($oScript)
        Do
            Sleep(250)
        Until $jsEval("typeof jQuery == 'function'")
    EndIf

    Do
        Sleep(250)
        $jQuery = $jsEval("jQuery")
    Until IsObj($jQuery)

    If $otherlib Then $jsEval('jQuery.noConflict();')

    Return $jQuery
EndFunc   ;==>_jQuerify

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • 4 weeks later...

Good job!

This will come in handy! 

 

EDIT

@Chimp

You can test all versions by using _IECreateEmbedded and setting FEATURE BROWSER EMULATION to emulate IE10 on Autoit.exe

 

#RequireAdmin

FEATURE_BROWSER_EMULATION("AutoIt3.exe", 10001)


Func FEATURE_BROWSER_EMULATION($sExe, $iVer)
    Local $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"
    Local $key64 = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"

    ; If OS IS 64 bit
    If @OSArch === "X64" Then $key = $key64

    RegWrite($key, $sExe, "REG_DWORD", $iVer)
    If @error Then Return SetError(@error)
EndFunc

 

Edited by tarretarretarre
Link to comment
Share on other sites

  • 1 month later...

Greetings,

  I am attempting to use this code so as to be able to expose Jquery commands to AutoIT.  It seems very promising however I keep getting this error:

$oIE.document.parentWindow.setTimeout('document.head.eval = eval', 0)
$oIE.document.parentWindow^ ERROR

it happens in the part where the function checks if the IE version is "11" or better...can I get some idea what the problem is here?  I'm using Windows 10.  I thank you in advance if anybody can give an explanation...

 

Link to comment
Share on other sites

Thank you for the reply.  As requested:

Edition:  Windows 10 Home
Version:  1703
OS Build:  15063.909
System Type:  64-bit operating system, x64-based processor

IE Info:  (from 'Details' tab in 'Properties' of iexplore.exe in the "Internet Explorer" folder)

File description:  Internet Explorer
Type:  Application
File Version:  11.0.15063.850
Product name:  Internet Explorer
Product Version:  11.00.15063.850
Date modified:  12/31/2017 6:17pm
Original filename:  IEXPLORE.EXE

 

  I actually seem to get the exact same error on 2 scripts I try to run...the first is the one from above, and the second is a script I believe that you ("Danp2") had provided on another post, if I am not mistaken.  I simply copied/pasted and ran both scripts...I did not make any changes or adjustments....

#include <ie.au3>

Example()

Func Example()
    Local $oIE = _IECreate("www.google.com")
    Local $jQuery = _jQuerify($oIE)

    MsgBox(0, "Version", "jQuery version: " & $jQuery.fn.jquery)
    MsgBox(0, "Example", "click ok to exit." & @CRLF & "Google logo will fade out by jQuery...")

    $jQuery('#hplogo').fadeOut(3000) ; jQuery will fade out the google logo
EndFunc   ;==>Example


; #FUNCTION# ====================================================================================================================
; Name ..........: _jQuerify
; Description ...:
; Syntax ........: _jQuerify(Byref $oIE)
; Parameters ....: $oIE                 - Object variable of an InternetExplorer.Application.
; Return values .: an object variable pointing to the jQuery library
; Author ........: Chimp
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _jQuerify(ByRef $oIE)

    Local $msie, $jsEval, $jQuery, $otherlib = False

    $msie = Execute('$oIE.document.documentMode')

    If ($msie = "") Or Number($msie) < 11 Then ; an IE version < 11
        ; create a reference to the javascript eval() function
        $oIE.document.parentWindow.setTimeout('window.eval = eval', 0)
        Do
            Sleep(250)
            $jsEval = Execute('$oIE.Document.parentwindow.eval')
        Until IsObj($jsEval)

    Else ; IE version > = 11
        ; create a reference to the javascript eval() function
        $oIE.document.parentWindow.setTimeout('document.head.eval = eval', 0)
        Do
            Sleep(250)
            $jsEval = Execute('$oIE.Document.head.eval')
        Until IsObj($jsEval)

    EndIf

    ; if jQuery is not already loaded then load it
    If $jsEval("typeof jQuery=='undefined'") Then

        ; check if the '$' (dollar) name is already in use by other library
        If $jsEval("typeof $=='function'") Then $otherlib = True

        Local $oScript = $oIE.document.createElement('script');
        $oScript.type = 'text/javascript'

        ; If you want to load jQuery from a disk file use the following statement
        ; where i.e. jquery-1.9.1.js is the file containing the jQuery source
        ; (or also use a string variable containing the whole jQuery listing)
;~ $oScript.TextContent = FileRead(@ScriptDir & "\jquery-1.9.1.js") ; <--- from a file

        ; If you want to download jQuery from the web use this statement
        $oScript.src = 'https://code.jquery.com/jquery-latest.min.js' ; <--- from an url


        $oIE.document.getElementsByTagName('head').item(0).appendChild($oScript)
        Do
            Sleep(250)
        Until $jsEval("typeof jQuery == 'function'")
    EndIf

    Do
        Sleep(250)
        $jQuery = $jsEval("jQuery")
    Until IsObj($jQuery)

    If $otherlib Then $jsEval('jQuery.noConflict();')

    Return $jQuery
EndFunc   ;==>_jQuerify

here is the second one (again same error on same line):

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $strMainURL = "http://bidfta.bidqt.com/BidFTA/#/Main"

Local $oIE = _IECreate($strMainURL)

MsgBox(0,"pause","Press ok when page is ready")

Local $oSelect = _IEGetObjByName($oIE, "LocationSelect")

;ControlSend("Main - Internet Explorer","","","e")

_IEFormElementOptionSelect($oSelect,"Amelia, OH",1,"byText")

Local $jQuery = _jQuerify($oIE)
$jQuery("[name='LocationSelect']").trigger('change')

MsgBox(0,"Done","Done")

_IEQuit($oIE)



; #FUNCTION# ====================================================================================================================
; Name ..........: _jQuerify
; Description ...:
; Syntax ........: _jQuerify(Byref $oIE)
; Parameters ....: $oIE                 - Object variable of an InternetExplorer.Application.
; Return values .: an object variable pointing to the jQuery library
; Author ........: Chimp
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _jQuerify(ByRef $oIE)

    Local $msie, $jsEval, $jQuery, $otherlib = False

    $msie = Execute('$oIE.document.documentMode')

    If ($msie = "") Or Number($msie) < 11 Then ; an IE version < 11
        ; create a reference to the javascript eval() function
        $oIE.document.parentWindow.setTimeout('window.eval = eval', 0)
        Do
            Sleep(250)
            $jsEval = Execute('$oIE.Document.parentwindow.eval')
        Until IsObj($jsEval)

    Else ; IE version > = 11
        ; create a reference to the javascript eval() function
        $oIE.document.parentWindow.setTimeout('document.head.eval = eval', 0)
        Do
            Sleep(250)
            $jsEval = Execute('$oIE.Document.head.eval')
        Until IsObj($jsEval)

    EndIf

    ; if jQuery is not already loaded then load it
    If $jsEval("typeof jQuery=='undefined'") Then

        ; check if the '$' (dollar) name is already in use by other library
        If $jsEval("typeof $=='function'") Then $otherlib = True

        Local $oScript = $oIE.document.createElement('script');
        $oScript.type = 'text/javascript'

        ; If you want to load jQuery from a disk file use the following statement
        ; where i.e. jquery-1.9.1.js is the file containing the jQuery source
        ; (or also use a string variable containing the whole jQuery listing)
;~ $oScript.TextContent = FileRead(@ScriptDir & "\jquery-1.9.1.js") ; <--- from a file

        ; If you want to download jQuery from the web use this statement
        $oScript.src = 'https://code.jquery.com/jquery-latest.min.js' ; <--- from an url


        $oIE.document.getElementsByTagName('head').item(0).appendChild($oScript)
        Do
            Sleep(250)
        Until $jsEval("typeof jQuery == 'function'")
    EndIf

    Do
        Sleep(250)
        $jQuery = $jsEval("jQuery")
    Until IsObj($jQuery)

    If $otherlib Then $jsEval('jQuery.noConflict();')

    Return $jQuery
EndFunc   ;==>_jQuerify

 

Any help is seriously appreciated...I really need to be able to use actual Jquery commands within AutoIT for a task I need to automate asap...

 

 

Link to comment
Share on other sites

Howdy,

  Thanks for the response.  I have updated my Windows 10.  The update took a while but seemed to go fine without any problems.  I now seem to be up to date and no additional updates are available at this time.  I still have exactly the same problem with this script.  Any work-arounds...?  Plan B...?  Thanks in advance.

Link to comment
Share on other sites

Hi again,

  I used the 'Developer Tools/Console' as suggested...using the browser window that opened up "Google" by running that first 'Jquerify' script.  I got a lot of "undefined" in [Object Window]...which I assume is not good...and likely the reason I cannot run these scripts...?

  Now the obvious question is what is causing this?  My OS is up to date with the latest updates, IE should be as well since Windows 10 keeps it so...'Active Scripting' is also 'enabled' within IE...what am I missing here?

thanks again for your help.

Link to comment
Share on other sites

Hi,

  Have not tried to implement a COM error handler yet...however from your first suggestion:

"

  • Open the IE Developer Tools by hitting F12
  • Switch to the console tab
  • Enter the string "document.parentWindow" (without the quotes)
  • Press Enter

"

  It reported a huge long list of items, however it begins with " [Object Window] " and then soon after lists 4 or 5 "undefined"...

  Am I correct in assuming there should be no "undefined" response from the "document.parentWindow" entry...?  If that is the case then that might give a reason why I cannot execute the script(s)...however I do not know what is necessary to correct this issue nor the cause of it. 

Link to comment
Share on other sites

3 minutes ago, Burgs said:

It reported a huge long list of items, however it begins with " [Object Window] " and then soon after lists 4 or 5 "undefined"...

No, that's actually what I would expect to see. So this simple test proves that the document.parentWindow object exists and is accessible from the developer tools. Now need to figure out why the command is failing from within the Autoit code.

Please report back once you've tested with a COM error handler in place.

Link to comment
Share on other sites

Hello again,

  I copied the COM ObjEvent script from the documentation...simply removing the 'intentional' error, as such:

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Error monitoring. This will trap all COM errors while alive.
    ; This particular object is declared as local, meaning after the function returns it will not exist.
    Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

    ; Create Internet Explorer object
    Local $oIE = ObjCreate("InternetExplorer.Application")
    ; Check for errors
    If @error Then Return

    $oIE.Visible = True ; set visibility

    ; Custom sink object
    Local $oIEEvents = ObjEvent($oIE, "_IEEvent_", "DWebBrowserEvents2")

    ; Navigate somewhere
    $oIE.navigate("http://www.google.com/")
    ; Check for errors while loading
    If @error Then
        $oIE.Quit()
        Return
    EndIf

    ; Wait for page to load
    While 1
        If $oIE.readyState = "complete" Or $oIE.readyState = 4 Then ExitLoop
        Sleep(10)
    WEnd

    ;; Deliberately cause error by calling non-existing method
    ;$oIE.PlayMeARockAndRollSong()

    ; Check for errors
    If @error Then MsgBox($MB_SYSTEMMODAL, "COM Error", "@error is set to COM error number." & @CRLF & "@error = 0x" & Hex(@error))

    ; Wait few seconds to see if more events will be fired
    Sleep(3000)

    ; Nothing more to do. Close IE and return from the function
    $oIE.Quit()

    #forceref $oErrorHandler, $oIEEvents
EndFunc   ;==>Example

; BeforeNavigate2 method definition
Func _IEEvent_BeforeNavigate2($oIEpDisp, $sIEURL, $iIEFlags, $sIETargetFrameName, $sIEPostData, $iIEHeaders, $bIECancel)
    ConsoleWrite("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--BeforeNavigate2 fired--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & _
            "$oIEpDisp = " & $oIEpDisp() & "  -  " & ObjName($oIEpDisp) & @CRLF & _ ; e.g. default property and name for the object
            "$sIEURL = " & $sIEURL & @CRLF & _
            "$iIEFlags = " & $iIEFlags & @CRLF & _
            "$sIETargetFrameName = " & $sIETargetFrameName & @CRLF & _
            "$sIEPostData = " & $sIEPostData & @CRLF & _
            "$iIEHeaders = " & $iIEHeaders & @CRLF & _
            "$bIECancel = " & $bIECancel & @CRLF & _
            "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & @CRLF)
EndFunc   ;==>_IEEvent_BeforeNavigate2

; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

 

  When I run this it does report the following problem in the debug console:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

ObjEvent_Test.au3 (51) : ==> COM Error intercepted !
    err.number is:         0x80070005
    err.windescription:    Access is denied.

    err.description is:     
    err.source is:         
    err.helpfile is:     
    err.helpcontext is:     
    err.lastdllerror is:     0
    err.scriptline is:     51
    err.retcode is:     0x00000000

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  Is that information useful...?  Forgive my ignorance I'm not familiar with usage of COM objects.  Thank you again for your help.

 

 

Edited by Burgs
Link to comment
Share on other sites

Hi,

  Not sure if I did this properly, but here is my code now (note:  I believe you intended to write 'ObjCreate' instead of  'IECreate')...so I commented out that line and inserted the '_IEAttach' line.

#include <IE.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Error monitoring. This will trap all COM errors while alive.
    ; This particular object is declared as local, meaning after the function returns it will not exist.
    Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

    ; Create Internet Explorer object
    ;Local $oIE = ObjCreate("InternetExplorer.Application")

Local $oIE = _IEAttach("Google")
MsgBox($MB_SYSTEMMODAL, "The URL", _IEPropertyGet($oIE, "locationurl"))

    ; Check for errors
    If @error Then Return

    $oIE.Visible = True ; set visibility

    ; Custom sink object
    Local $oIEEvents = ObjEvent($oIE, "_IEEvent_", "DWebBrowserEvents2")

    ;; Navigate somewhere
    ;$oIE.navigate("http://www.google.com/")
    ;; Check for errors while loading
    ;If @error Then
    ;   $oIE.Quit()
    ;   Return
    ;EndIf

    ; Wait for page to load
    While 1
        If $oIE.readyState = "complete" Or $oIE.readyState = 4 Then ExitLoop
        Sleep(10)
    WEnd

    ;; Deliberately cause error by calling non-existing method
    ;$oIE.PlayMeARockAndRollSong()

    ; Check for errors
    If @error Then MsgBox($MB_SYSTEMMODAL, "COM Error", "@error is set to COM error number." & @CRLF & "@error = 0x" & Hex(@error))

    ; Wait few seconds to see if more events will be fired
    Sleep(3000)

    ; Nothing more to do. Close IE and return from the function
    $oIE.Quit()

    #forceref $oErrorHandler, $oIEEvents
EndFunc   ;==>Example

; BeforeNavigate2 method definition
Func _IEEvent_BeforeNavigate2($oIEpDisp, $sIEURL, $iIEFlags, $sIETargetFrameName, $sIEPostData, $iIEHeaders, $bIECancel)
    ConsoleWrite("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--BeforeNavigate2 fired--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & _
            "$oIEpDisp = " & $oIEpDisp() & "  -  " & ObjName($oIEpDisp) & @CRLF & _ ; e.g. default property and name for the object
            "$sIEURL = " & $sIEURL & @CRLF & _
            "$iIEFlags = " & $iIEFlags & @CRLF & _
            "$sIETargetFrameName = " & $sIETargetFrameName & @CRLF & _
            "$sIEPostData = " & $sIEPostData & @CRLF & _
            "$iIEHeaders = " & $iIEHeaders & @CRLF & _
            "$bIECancel = " & $bIECancel & @CRLF & _
            "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & @CRLF)
EndFunc   ;==>_IEEvent_BeforeNavigate2

; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

 

  I manually opened up an IE browser and typed in 'www.google.com' into the search bar.  When the page was loaded I ran this script above.  Here are the complete debug console notifications:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\Stephen\Desktop\ObjEvent_Test.au3"    
--> IE.au3 T3.0-2 Warning from function _IEAttach, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
ObjEvent_Test.au3 (350) : ==> COM Error intercepted !
    err.number is:         0x80020009
    err.windescription:    Exception occurred.

    err.description is:     
    err.source is:         
    err.helpfile is:     
    err.helpcontext is:     0
    err.lastdllerror is:     0
    err.scriptline is:     350
    err.retcode is:     0x80004002

--> IE.au3 T3.0-2 Warning from function _IEAttach, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function _IEAttach, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
>Exit code: 0    Time: 6.325

  I hope that is along the lines of what you were instructing me to do...and if so then I hope it is helpful information.  Thanks again.

 

Link to comment
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
 Share

×
×
  • Create New...