oMBRa Posted April 17, 2009 Share Posted April 17, 2009 is possible to handle the close event of IE as we can do with gui :GUISetOnEvent($GUI_EVENT_CLOSE, 'myfunc') Link to comment Share on other sites More sharing options...
Authenticity Posted April 17, 2009 Share Posted April 17, 2009 Yes, http://msdn.microsoft.com/en-us/library/aa...28VS.85%29.aspx.Use ObjEvent to declare your event procedure prefix and use the OnQuit event. Link to comment Share on other sites More sharing options...
oMBRa Posted April 17, 2009 Author Share Posted April 17, 2009 is possibile to prevent it to be closed? Link to comment Share on other sites More sharing options...
DaleHohm Posted April 17, 2009 Share Posted April 17, 2009 is possibile to prevent it to be closed?Not from AutoIt. AutoIt handles COM event asynchronously, so you cannot Cancel them.You can use _IEHeadInsertEventScript to inject Javascript onto the page and handle the event from there.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...
oMBRa Posted April 18, 2009 Author Share Posted April 18, 2009 wich is the name of the event when u click the close button? I tried ''OnQuit'' with no results Link to comment Share on other sites More sharing options...
DaleHohm Posted April 18, 2009 Share Posted April 18, 2009 OnQuit is an event on the internetexplorer object that is not accessible to the DOM, but you can trap the onbeforeunload event of the window object that gets fired before a Quit. _IEHeadInsertEventScript ($oIE, "window", "onbeforeunload", "your script") 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...
oMBRa Posted April 18, 2009 Author Share Posted April 18, 2009 Thanks for your help Dale, but now whenever you click the close button, IE dislays an annoying message that asks you if u want exit or not... is there any event that can be handled to prevent to dislay that mesage? Link to comment Share on other sites More sharing options...
Authenticity Posted April 18, 2009 Share Posted April 18, 2009 Try this: #include <IE.au3> HotKeySet('{ESC}', '_EXIT') Dim $sKey = 'HKCU\Software\Microsoft\Internet Explorer\New Windows' RegWrite($sKey, 'PopupMgr', 'REG_SZ', 'no') Dim $o_IE = _IECreate('http://www.autoitscript.com/') _IEHeadInsertEventScript($o_IE, 'window', 'onunload', 'window.open("about:blank");') While 1 Sleep(20) WEnd Func _EXIT() RegWrite($sKey, 'PopupMgr', 'REG_SZ', 'yes') Exit EndFunc Link to comment Share on other sites More sharing options...
oMBRa Posted April 18, 2009 Author Share Posted April 18, 2009 it keeps showing that message, dont know why Link to comment Share on other sites More sharing options...
DaleHohm Posted April 18, 2009 Share Posted April 18, 2009 Thanks for your help Dale, but now whenever you click the close button, IE dislays an annoying message that asks you if u want exit or not... is there any event that can be handled to prevent to dislay that mesage?Sorry. From MSDN:When a string is assigned to the returnValue property of window.event, a dialog box appears that gives users the option to stay on the current page and retain the string that was assigned to it. The default statement that appears in the dialog box, "Are you sure you want to navigate away from this page? ... Press OK to continue, or Cancel to stay on the current page.", cannot be removed or altered.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...
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