Jump to content

_IEAttach crashes


Recommended Posts

Good day,

I try to use _IEAttach with $s_mode = HTML:

#include <IE.au3>
Dim $oIE
While IsObj($oIE) = 0
        $oIE = _IEAttach("...some html...", "HTML")
        If IsObj($oIE) Then
 ;do some stuff
    EndIf
Sleep(1000)
Wend

If the web page I want to attach to is already present, it works fine. But if the page is just loading, the script crashes at that moment:

C:\Program Files\AutoIt3\Include\IE.au3 (456) : ==> Variable must be of type "Object".:
If StringInStr($o_window.document.body.innerHTML, $s_string) > 0 Then
If StringInStr($o_window.document.body^ ERROR
->00:03:54 AutoIT3.exe ended.rc:1
>Exit code: 1   Time: 8.053

If I use other attach modes(Title, URL, Text, etc.) it also works fine. What could be the problem? I would greatly appreciate any help, as its really driving me nuts :mellow:

Link to comment
Share on other sites

That's not a crash, just an error, and your script continues executing. The $o_window.document.body is not a retrievable object until the page is done loading.

Seems pretty simple: Don't try to attach by that mode before it's loaded.

:mellow:

Edit: More accurately, it doesn't have to be a crash. Add _IEErrorHandlerRegister().

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Why must you use only "HTML" mode for _IEAttach()? Either find it another way and _IELoadWait(), or do it in a loop (with proper error handling) until you get the one you want.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...