Jump to content

Recommended Posts

Posted

Hello everyone, this is my first post here. I'm a relative novice in autoit and have only picked it up in the past month. Currently i'm working on a project at work to automate the downloading of a bank statement from the bank's website. The main problem that I'm having is doing error handling when an error happened because the website crashed / timeout. I'm trying to capture the error event when one of my _IE functions failed to load because the page is frozen.

Here is a snippet of my code:

Func Test()
    Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

    $WinHandle = WinGetHandle("Test Website")
    $oIE = _IEAttach($WinHandle, "hwnd")

    $oFrame = _IEFrameGetObjByName($oIE, "leftFrame")
    $oDiv = _IEGetObjById($oFrame, "divFoldCont")
    $oDiv2 = _IEGetObjById($oDiv, "divFold0")
    $oDiv3 = _IEGetObjById($oDiv2,"divFoldSub0_1")
    $oLinks = _IELinkClickByText($oDiv3, "Bank Statement")
    Sleep(1000)
    
    ; Enter the Account Number
    $oFrame = _IEFrameGetObjByName($oIE, "workspace")
    $oLinks = _IELinkGetCollection($oFrame)

    For $oLink in $oLinks
        ;ConsoleWrite($oLink.href)
        _IEAction($oLink, "click")
        sleep(1000)
        ExitLoop
    Next
EndFunc

Func _ErrFunc($oError)

        $ErrorMessage = (@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 was planning for the program to send me an automated email to let me know that the program had crashed. This email will be triggered when an error event is captured. However here lies the problem. My script will always capture the following error message even when everything is working. The error message occur during _IEAttach.

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

How do I modify my script so that this particular error won't trigger my error function?

P.S I'm open to suggestions on any advice to improve on my script.

P.S.S I can't use _IECreate because the website require me to login using a physical OTP, so I have to login to the website first before running the script.

Thanks for any guidance

Posted (edited)

Please read here:

   ie.au3 UDF with AutoIt v3.3.14.x  

btw.

Welcome to the forum

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 12/2/2015 at 11:12 AM, Skystrike said:

Hello everyone, this is my first post here. I'm a relative novice in autoit and have only picked it up in the past month. Currently i'm working on a project at work to automate the downloading of a bank statement from the bank's website. The main problem that I'm having is doing error handling when an error happened because the website crashed / timeout. I'm trying to capture the error event when one of my _IE functions failed to load because the page is frozen.

Whats mean "frozen" is that entire iexploerer.exe not responding, or only this particular website is frozen and IE is still operative  ?


Func Test()
    Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

When you declare any variable in local scope then it is visible inside any other function even in _IE.... functions.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 12/2/2015 at 12:27 PM, Danp2 said:

Try changing:

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

to:

_IEErrorHandlerRegister("_ErrFunc")

 

Let me try this out. Does this mean that all of the error in the script will be handled by _IEErrorHandlerRegister ? What is the difference between this and the previous method that i tried?

  On 12/2/2015 at 9:12 PM, mLipok said:

Whats mean "frozen" is that entire iexploerer.exe not responding, or only this particular website is frozen and IE is still operative  ?

 


Func Test()
    Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

When you declare any variable in local scope then it is visible inside any other function even in _IE.... functions.

 

The website is frozen (Most likely it timed out). I will read through the post that you linked above and try it again.

 

Thanks all for the warm welcome

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.
×
×
  • Create New...