Deltron0 Posted July 8, 2012 Share Posted July 8, 2012 (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 July 8, 2012 by Deltron0 Link to comment Share on other sites More sharing options...
JohnOne Posted July 8, 2012 Share Posted July 8, 2012 Register an error handler... _IEErrorHandlerRegister("_func") <- help file. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Deltron0 Posted July 8, 2012 Author Share Posted July 8, 2012 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 Link to comment Share on other sites More sharing options...
JohnOne Posted July 9, 2012 Share Posted July 9, 2012 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. Link to comment Share on other sites More sharing options...
Deltron0 Posted July 10, 2012 Author Share Posted July 10, 2012 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 Link to comment Share on other sites More sharing options...
JohnOne Posted July 10, 2012 Share Posted July 10, 2012 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 existin the first place.Where you are returning from the function after that msgbox, it should Return False, and thefunction 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. Link to comment Share on other sites More sharing options...
Deltron0 Posted July 10, 2012 Author Share Posted July 10, 2012 It works now, needed to add that timeout. Thanks 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