XGhosT Posted September 21, 2009 Share Posted September 21, 2009 Good afternoon ! Please, help me with my code: i have strange error while run this code: In this code i create main window with embedding IE window frame. In IE frame i injected HTML code with one button and set event on this button. If you press button, event fired and run 'Event_IE_BTN_onclick' that create new window with embedding new IE. While i injecting any code or run _IELoadWait, AutoIt Crashed with strange errors. Please, help! expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC",1) Global $MainWindow = GUICreate("Main Window", 233, 122, 335, 214) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEMain", $MainWindow) $ieFrame = _IECreateEmbedded () GUICtrlCreateObj($ieFrame, 10, 10, 200, 100) $ieFrame.navigate("about:blank") _IELoadWait($ieFrame) _IEDocWriteHTML($ieFrame, "<html><body><button name='BTN'>Press This</button></body></html>") _IELoadWait($ieFrame) ObjEvent(_IEGetObjById($ieFrame, "BTN"), "Event_IE_BTN_") _IEErrorHandlerRegister("MyErrFunc") GUISetState(@SW_SHOW, $MainWindow) ; will display an empty dialog box While 1 Sleep(1000) ; Idle around WEnd Exit ;-- Open new window when button in 'IE' pressed Func Event_IE_BTN_onclick() Global $ParentWindow = GUICreate("Parent Window", 233, 122, 335, 214) $ieParentFrame = _IECreateEmbedded () GUICtrlCreateObj($ieParentFrame, 10, 10, 200, 100) $ieParentFrame.navigate("about:blank") _IELoadWait($ieParentFrame) ;-- Crashed here !!! _IEDocWriteHTML($ieParentFrame, "<html><body>Simple Text</body></html>") ;-- Crashed here !!! _IELoadWait($ieParentFrame) ;-- Crashed here !!! EndFunc ;-- Close main window Func CLOSEMain() Exit EndFunc ;-- My Error Handler Func MyErrFunc() SetError(0,0,0) Return EndFunc ;==>MyErrFunc Link to comment Share on other sites More sharing options...
jvanegmond Posted September 21, 2009 Share Posted September 21, 2009 You're getting an error but it doesn't crash. Some improvements made: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC",1) Global $MainWindow = GUICreate("Main Window", 233, 122, 335, 214) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEMain", $MainWindow) $ieFrame = _IECreateEmbedded () GUICtrlCreateObj($ieFrame, 10, 10, 200, 100) _IENavigate($ieFrame, "about:blank") _IEDocWriteHTML($ieFrame, "<html><body><button id=""BTN"">Press This</button></body></html>") _IELoadWait($ieFrame) $obj = _IEGetObjById($ieFrame, "BTN") ObjEvent($obj, "Event_IE_BTN_") _IEErrorHandlerRegister("MyErrFunc") GUISetState(@SW_SHOW, $MainWindow) ; will display an empty dialog box While 1 Sleep(1000) ; Idle around WEnd Exit ;-- Open new window when button in 'IE' pressed Func Event_IE_BTN_onclick() Global $ParentWindow = GUICreate("Parent Window", 233, 122, 335, 214) $ieParentFrame = _IECreateEmbedded () GUICtrlCreateObj($ieParentFrame, 10, 10, 200, 100) _IENavigate($ieParentFrame, "about:blank") _IEDocWriteHTML($ieParentFrame, "<html><body>Simple Text</body></html>") _IELoadWait($ieParentFrame) GUISetState() EndFunc ;-- Close main window Func CLOSEMain() Exit EndFunc ;-- My Error Handler Func MyErrFunc() SetError(0,0,0) Return EndFunc ;==>MyErrFunc github.com/jvanegmond Link to comment Share on other sites More sharing options...
XGhosT Posted September 21, 2009 Author Share Posted September 21, 2009 Yes, i getting error. But if you modify code for closing popup window and click five or six times on button (and close pop up window, of course), Auto It crashed. For my application this is really big problem ;-( Link to comment Share on other sites More sharing options...
jvanegmond Posted September 21, 2009 Share Posted September 21, 2009 With my script, I have no problems running 50 instances of the GUI. It doesn't crash. github.com/jvanegmond Link to comment Share on other sites More sharing options...
DaleHohm Posted September 21, 2009 Share Posted September 21, 2009 What error do you get using the standard _IEErrorHandlerRegister() instead of your custom handler? 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...
XGhosT Posted September 22, 2009 Author Share Posted September 22, 2009 What error do you get using the standard _IEErrorHandlerRegister() instead of your custom handler?If i use _IEErrorHandlerRegister(), and seen this error message--> COM Error Encountered in IEErrSample.au3----> $IEComErrorScriptline = ----> $IEComErrorNumberHex = 00000000----> $IEComErrorNumber = ----> $IEComErrorWinDescription = ----> $IEComErrorDescription = ----> $IEComErrorSource = ----> $IEComErrorHelpFile = ----> $IEComErrorHelpContext = ----> $IEComErrorLastDllError = When i not use any error handler (i think, in this cause uses internal handler)C:\Program Files\AutoIt3\Include\IE.au3 (4341) : ==> Variable must be of type "Object".:$IEComErrorScriptline = $oIEErrorHandler.scriptline$IEComErrorScriptline = $oIEErrorHandler^ ERROR->07:58:29 AutoIT3.exe ended.rc:1 I think, this strange behaviour of IE component is caused by incorrect handling of events: error error occurs only when creating a new window with IE in the processing of event (onclick in my sample) P.S. I ran the code in this style on different computers (WinXP, IE7/IE8) and all the time the result was the same: there was an error and after a few opened windows AutoIT crashed Link to comment Share on other sites More sharing options...
jvanegmond Posted September 22, 2009 Share Posted September 22, 2009 Must be something strange you are doing. I have just tried this on second computer and it was fine.First test was on Win7 with IE8 and second test was on Win Vista with IE8. I have an old Win XP machine with IE6 I can test it on, but I'll need to dust it off.. github.com/jvanegmond 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