grzesiek Posted May 13, 2008 Share Posted May 13, 2008 (edited) Does anyone know why I'm getting error while running this script? This script should close new opened window in IE and it does but then I'm getting this error: $IEComErrorScrptline = $oIEErrorHandler.scriptline $IEComErrorScrptline = $oIEErrorHandler^ERROR Error: Variable must be of type "Object". #include <IE.au3> Const $navOpenInNewWindow = 0x1 $oIE1 = _IECreate("http://www.autoitscript.com/autoit3/") $oEvent = ObjEvent($oIE1, "IEEvent_", "DWebBrowserEvents") __IENavigate($oIE1, "http://www.autoitscript.com/autoit3/downloads.shtml", 1, $navOpenInNewWindow) While 1 Sleep(5000) WEnd Func IEEvent_NewWindow($Url, $Cancel) $oIE2 = _IEAttach($Url, "URL") While @error $oIE2 = _IEAttach($Url, "URL") WEnd _IEQuit($oIE2) EndFunc Edited May 13, 2008 by grzesiek Link to comment Share on other sites More sharing options...
DaleHohm Posted May 14, 2008 Share Posted May 14, 2008 This is nasty. Sorry. _IEAttach instantiates a COM error handler that is not tolerant of asynchronous entry like this. I suggest you avoid the issue by using NewWindow2 or NewWindow3 events that both pass an object reference to the new browser window instead of using _IEAttach to get it indirectly. 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 Link to comment Share on other sites More sharing options...
grzesiek Posted May 14, 2008 Author Share Posted May 14, 2008 Can you show me how can I change to NewWindow2 or NewWindow3 because I tried and it didn't work? Link to comment Share on other sites More sharing options...
DaleHohm Posted May 14, 2008 Share Posted May 14, 2008 I haven't done it, just read about it. Please show what you tried. 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 Link to comment Share on other sites More sharing options...
grzesiek Posted May 14, 2008 Author Share Posted May 14, 2008 (edited) I changed script to this and it doesn't work. Message box should appear when second window is about to open but it doesn't. #include <IE.au3> Const $navOpenInNewWindow = 0x1 $oIE = _IECreate("http://www.autoitscript.com/autoit3/") $oEvent = ObjEvent($oIE, "IEEvent_", "DWebBrowserEvents2") __IENavigate($oIE, "http://www.autoitscript.com/autoit3/downloads.shtml", 1, $navOpenInNewWindow) Func IEEvent_NewWindow2($ppDisp, $Cancel) MsgBox(0,"","") EndFunc I also tried this: Const $navOpenInNewWindow = 0x1 $oIE = ObjCreate("InternetExplorer.Application") $oEvent = ObjEvent($oIE, "IEEvent_", "DWebBrowserEvents2") $oIE.Visible = True $oIE.Navigate("http://www.autoitscript.com/autoit3/") While $oIE.Busy = True Sleep(500) WEnd $oIE.Navigate("http://www.autoitscript.com/autoit3/downloads.shtml", $navOpenInNewWindow) Func IEEvent_NewWindow2($ppDisp, $Cancel) MsgBox(0,"","") EndFunc Edited May 14, 2008 by grzesiek Link to comment Share on other sites More sharing options...
DaleHohm Posted May 14, 2008 Share Posted May 14, 2008 You're right. The NewWindow2 and NewWindow3 events are either not firing or are not being trapped. I cannot explain it. As a workaround, it appears taht if you add _IEErrorHandlerRegister() to your script, you will no longer encounter a fatal error and your script can continue. 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 Link to comment Share on other sites More sharing options...
grzesiek Posted May 14, 2008 Author Share Posted May 14, 2008 Thanks for this tip with _IEErrorHandlerRegister() 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