Jump to content
Sign in to follow this  
Teldin

IE.au3 Help needed

Recommended Posts

Teldin

C:\PROGRA~1\AutoIt3\Include\IE.au3 (2659) : ==> The requested action with this object has failed.:

$o_object.document.execCommand ("Refresh")

$o_object.document^ ERROR

Basically I have a timed script that opens a web page (after I log in) and ever 10 mins or so checks the site for changes. I get an error If I get logged out because while the object is still valid, the Refresh command fails as the specified page cannot be accessed. I dont mind any of this but my script crashes. I need to gracefully error and continue with my script. How can I do that?

Here is some code:

$Timer10 = TimerInit()

;portion of my main loop
While 1
    Sleep(50)
    If TimerDiff($Timer10) >= 600000  Then
        _Data1()
    Else
    EndIf
Wend

;func I'm having problems with
Func _Data1()
    GUICtrlSetData($status, "Checking news...")
    If IsObj($oIE2) Then
        _IEAction($oIE2, "refresh")
        If @error <> 0 Then              ;I recently added this IF to try and error gracefully but it didn't work
            MsgBox(0, "ERROR", "You have been logged out")
            GUICtrlSetData($status, "ERROR: Not checking news")
            $stopie = 1
        Else
            _IELoadWait($oIE2, 1000)
            $sText = _IEBodyReadText($oIE2)
            $ltrim = StringTrimLeft($sText, 115)
            $rtrim = StringTrimRight($ltrim, 301)
            If StringInStr($rtrim, "New") Or StringInStr($rtrimID, "New") Then
                GUICtrlSetData($status, "ERROR: News window lost")
                KillIE()
            Else
            EndIf
        Endif   
    Else
        GUICtrlSetData($status, "ERROR: News window lost")
        $stopie = 1
    EndIf
    GUICtrlSetData($status, "Ready...")
EndFunc

Any ideas?

I dont have your _IEErrorHandler installed. Would that help at all?

Edited by Teldin

Share this post


Link to post
Share on other sites
big_daddy

I dont have your _IEErrorHandler installed. Would that help at all?

That is what it was made for.

Just add this toward the top of your script.

_IEErrorHandlerRegister()
Edited by big_daddy

Share this post


Link to post
Share on other sites
Teldin

Ok let me try that. I was thinking it only helps finding problems and I alread know what the problem is.

Share this post


Link to post
Share on other sites
Teldin

Ok that seemed to work. It's not crashing now. Also returning the error as expected:

--> IE.au3 Error from function _IELoadWait, $_IEStatus_InvalidObjectType

--> IE.au3 Error from function _IEBodyReadText, $_IEStatus_InvalidObjectType (Expected document element)

--> COM Error Encountered in test.au3

----> $IEComErrorScriptline = 437

----> $IEComErrorNumberHex = 80010108

----> $IEComErrorNumber = -2147417848

----> $IEComErrorWinDescription = The object invoked has disconnected from its clients.

----> $IEComErrorDescription =

----> $IEComErrorSource =

----> $IEComErrorHelpFile =

----> $IEComErrorHelpContext =

----> $IEComErrorLastDllError = 0

Thanks big daddy.

Share this post


Link to post
Share on other sites
Teldin

One last thing, can I change my "If @error <> 0 " to be able to catch the com error?

Share this post


Link to post
Share on other sites
DaleHohm

One last thing, can I change my "If @error <> 0 " to be able to catch the com error?

Yes, @error get set to the global constant $_IEStatus_ComError

Also, look at the console output... all of those $IEComError* are global variables that you can examine the value of after a COM error.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.