StandardUser Posted June 20, 2010 Share Posted June 20, 2010 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 Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 21, 2010 Share Posted June 21, 2010 (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. Edit: More accurately, it doesn't have to be a crash. Add _IEErrorHandlerRegister(). Edited June 21, 2010 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 More sharing options...
StandardUser Posted June 21, 2010 Author Share Posted June 21, 2010 Thanks a lot, you made my day 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 Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 21, 2010 Share Posted June 21, 2010 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. 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 More sharing options...
StandardUser Posted June 21, 2010 Author Share Posted June 21, 2010 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! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now