Sign in to follow this  
Followers 0
Deltron0

_IENavigate - Handle IE crashing or closing in any way

7 posts in this topic

#1 ·  Posted (edited)

#include <IE.au3>
$myIE = _IECreate()
_IENavigate($myIE, "http://dictionary.com")
If @error Then MsgBox(0,"Error","Internet Explorer closed unexpectedly") ;this does not behave as expected, if IE is closed while the page is loading the autoit app will shutdown completely

I'm attempting to navigate to a webpage with the eventual goal of collecting data from it that will then be returned to the AutoIT application as variables. However, if the page is taking too long to load and the user closes Internet Explorer, the application will crash and end completely. Apparently IE closing does not return @error and thus my existing code does nothing to fix the problem.

Any help would be very much appreciated.

Edited by Deltron0

Share this post


Link to post
Share on other sites



Perhaps my issue is misunderstood. If IE is closed, I want to exit the function from which I'm opening IE.

#include <IE.au3>
DoIEstuff()
Func DoIEstuff()
$myIE = _IECreate()
_IENavigate($myIE, "http://dictionary.com")
If @error Then
MsgBox(0,"Error","Internet Explorer closed unexpectedly") ;this does not behave as expected, if IE is closed while the page is loading the autoit app will shutdown completely
Return
EndIf
EndFunc

When this code executes IE will open and attempt to load "dictionary.com", which the user can close. If the user closes IE before it's finished loading the application will quit entirely.

Console shows:

C:Program Files (x86)AutoIt3IncludeIE.au3 (560) : ==> The requested action with this object has failed.:

WEnd

WEnd^ ERROR

Share this post


Link to post
Share on other sites

I still think the answer (which is probably cleaner than my effort below) still lies

in a error handler.

#include <IE.au3>

Global $IEERROR = False
Global $myIE

_IEErrorHandlerRegister("MyErrFunc")

DoIEstuff()

Func DoIEstuff()
   $myIE = _IECreate()
   _IENavigate($myIE, "http://dictionary.com",0) ; don't wait
   _IELoadWait($myIE, 0, 5000) ; 5 second timeout
   If $IEERROR Then
      MsgBox(0,"Error","Internet Explorer closed unexpectedly");this does not behave as expected, if IE is closed while the page is loading the autoit app will shutdown completely
      Return
   EndIf
EndFunc ;==>DoIEstuff

Func MyErrFunc()
   $IEERROR = True
   Return
EndFunc ;==>MyErrFunc

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

I'd like to thank you for looking into this so far. I implemented the code above, a major problem now is that the event keeps triggering and I don't know how to stop the application from trying to do the background operations with Internet Explorer.

Global $IEERROR = False
Global $myIE
_IEErrorHandlerRegister("MyErrFunc")
DoIEstuff()
Func DoIEstuff()
   $myIE = _IECreate()
   _IENavigate($myIE, "http://dictionary.com",0) ; don't wait
   _IELoadWait($myIE, 0, 5000) ; 5 second timeout
   If $IEERROR Then
      MsgBox(0,"Error","Internet Explorer closed unexpectedly");this does not behave as expected, if IE is closed while the page is loading the autoit app will shutdown completely
      Return
   EndIf
EndFunc ;==>DoIEstuff
Func MyErrFunc()
   $IEERROR = True
   StopTryingToUseIE() ;need something to happen makes the script stop using IE or resets the entire script
_IEErrorHandlerDeRegister ;this doesn't help
   Return ;this doesn't work, it returns to trying what causes the error in the first place
EndFunc ;==>MyErrFunc

Share this post


Link to post
Share on other sites

Without a runnable example of your issue, it's almost impossible to diagnose it.

My thoughts are, that your script should not be trying to use an instance of IE that does not exist

in the first place.

Where you are returning from the function after that msgbox, it should Return False, and the

function it returns to should not attempt to do these "background operations with Internet Explorer".


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

It works now, needed to add that timeout. Thanks 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