Sign in to follow this  
Followers 0
StandardUser

_IEAttach crashes

5 posts in this topic

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:

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Thanks a lot, you made my day :mellow: I really forgot about _IEErrorHandlerRegister. It now prevents the script from exiting. However I think, it is not a good solution to make a buggy script work properly, but I see no other method :P

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

The page I want to attach to is only distinguishable by its HTML, no other attach mode is reliable, anyway, thanks for your help again!

Share this post


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
Sign in to follow this  
Followers 0