Jump to content

Stop fatal errors from crashing script run


Recommended Posts

6 hours ago, SchneiMi said:

Execute("$oIE.document.location.href = 'http://www.leo.org'")  ;; @error = 0, but site is not loaded

 

by doing this it test if $oIE.document.location.href equal to 'http://www.leo.org' if yes then return 1 else it return 0.

you can use execute to test if code doesn't throw error (Crash the script) but not use it change variable data.

Link to comment
Share on other sites

13 hours ago, farouk12 said:

by doing this it test if $oIE.document.location.href equal to 'http://www.leo.org' if yes then return 1 else it return 0.

you can use execute to test if code doesn't throw error (Crash the script) but not use it change variable data.

Thanks for the notice. Sounds like what I've read in the old script. But it's not the intuitive and expected behaviour, as Eval is supposed to evaluate and return expressions and comparisons, while Excecute is expected to perform Actions/methods and assignments, as it works in Python, CA-Realizer and any other language I know that Supports execute Statements. At least it should be mentioned in the documentation (that it unexpectedly works like Eval for assignments).

However, in my case, this Workaround is not useful, then. Because the test for Access to the com object/method works fine, but the Problem Comes from the actual assignment, which throws the fatal autoit error.

 

Link to comment
Share on other sites

On ‎08‎.‎01‎.‎2018 at 3:09 PM, water said:

Which version of AutoIt do you run? There is a bug in AutoIt after 3.3.12.0 where nested COM operations that result in an error crash the script.

Hello water,

I have designed a test script, according to how I understood your description and Workaround. I have two modes that do the same Thing, open a Website and reading the href prop of some arbitrary link. But in one mode, I Access the property in one chain call, in the other I split the path and always call the next element on the previously created AutoIt variable/pointer. The only Thing I do not recreate every Loop, is the reference to the Webbrowser.

But as a result, the program crashes in both modes between roughly 4080 and 4150 Loops (quite reproducibly).

Here's the Code. The run takes some time, but I would highly appreciate if someone could tell me if it crashes there, too. I use a Laptop with Windows 10 Enterprise, btw:

Quote

 

#include <IE.au3>

 

;;             sMode choices

;;                            "chain"    : access a long com path

;;      "separate" : split path and access com objects one by one

$sMode = "separate"

 

_IEErrorHandlerRegister()

 

Switch $sMode Then

    Case "chain"

        Local $iCount = 0

        Local $oIE = _IECreate("www.leo.org")

        Local $s = ""

        Local $err = Null

        While True

            $iCount += 1

            $s = $oIE.document.getElementsByTagName("a")(2).href

            $err = @error

            ConsoleWrite("" & $iCount & ". " & $s & " - " & $err & @CRLF)

            If $err Then ExitLoop

            Sleep(200)

        WEnd

 

    Case "separate"

        Local $iCount = 0

        Local $oIE = _IECreate("www.leo.org")

        Local $s = ""

        Local $err = Null, $oDoc = Null, $oLinks = Null, $oLink = Null

        While True

            $iCount += 1

            $oDoc = $oIE.document

            $oLinks = $oDoc.getElementsByTagName("a")

            $oLink = $oLinks(2)

            $s = $oLink.href

            $err = @error

            ConsoleWrite("" & $iCount & ". " & $s & " - " & $err & @CRLF)

            If $err Then ExitLoop

            Sleep(200)

        WEnd

EndSwitch

 

Screenshot of two runs' Errors (mode "chain" with long com object paths) is attached.

The last lines with error message from mode 2 (split com object calls) is as follows:

Quote

 

4153. https://dict.leo.org/forum/index.php?lp=ende&lang=de&pos=6 - 0

4154. https://dict.leo.org/forum/index.php?lp=ende&lang=de&pos=6 - 0

--> COM Error encountered in com_test.au3 (33) :

----> $IEComErrorNumber             = 0x80020008 (-2147352568)

----> $IEComErrorWinDescription              = Falscher Variablentyp.

----> $IEComErrorDescription       =

----> $IEComErrorSource               =

----> $IEComErrorHelpFile             =

----> $IEComErrorHelpContext     =

----> $IEComErrorLastDllError      = 0

----> $IEComErrorRetcode            = 0x00000000

"C:\Users\ng1e2ed\Documents\com_test.au3" (34) : ==> Variable cannot be accessed in this manner.:

$oLink = $oLinks(2)

$oLink = $oLinks^ ERROR

>Exit code: 1    Time: 878.5

 

Did I make a mistake? It Looks like I'm at a dead end. Isn't there any way to prevent the reference from breaking? If I don't Exit the Loop, the behaviour still doesn't go back to normal.

 

I am open for any ideas! Thank you

Michael

 

autoit_error_messages_compath.png

Link to comment
Share on other sites

It would be very nice, if someone would test the script, please!

Or the even Shorter one in my stackoverflow - post: 48283903/internet-explorer-com-objects-accessed-by-autoit-stop-working-during-runtime

When compiled to exe, no error seems to occur. Neither on my Win 10 Laptop, only on the Win 7 64-bit Laptop. A friend of mine tested on his Win7 64-bit and it crashed, too.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...