cyanidemonkey Posted January 26, 2006 Posted January 26, 2006 Can anyone see why this GUI will not close when the red X is clicked? The minimise and restore work ok. #include <GUIConstants.au3> #include <IE.au3> HotKeySet("{ESC}", "Terminate") GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") GUICreate("TRANSPOWER - Induction, Stage 1 Welcome.",899, 674) Opt("ExpandVarStrings", 1) $oIE = ObjCreate("Shell.Explorer.2") $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 900,675) $oIE.navigate("@ScriptDir@\test.html") $oIE.document.body.scroll = "no" $oIE = 0 GUISetState() While 1 Sleep(1000) Wend Func Terminate() Exit 0 EndFunc Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE Case @GUI_CtrlId = $GUI_EVENT_RESTORE EndSelect EndFunc My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator
Moderators SmOke_N Posted January 26, 2006 Moderators Posted January 26, 2006 (edited) Well one, your using GUISetOnEvent() and you don't have: Opt('GUIOnEventMode', 1) and for 2.. you have case @GUI_CtrlId = $GUI_EVENT_CLOSE.. but you not telling it to exit if it's true: Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Exit Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE Case @GUI_CtrlId = $GUI_EVENT_RESTORE EndSelect EndFunc Edited January 26, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
cyanidemonkey Posted January 26, 2006 Author Posted January 26, 2006 updated code as below, but still will not close... #include <GUIConstants.au3> #include <IE.au3> Opt("GUIOnEventMode", 1) HotKeySet("{ESC}", "Terminate") GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") GUICreate("TRANSPOWER - Induction, Stage 1 Welcome.",899, 674) Opt("ExpandVarStrings", 1) $oIE = ObjCreate("Shell.Explorer.2") $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 900,675) $oIE.navigate("@ScriptDir@\test.html") $oIE.document.body.scroll = "no" $oIE = 0 GUISetState() While 1 Sleep(1000) Wend Func Terminate() Exit 0 EndFunc Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Exit 0 Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE Case @GUI_CtrlId = $GUI_EVENT_RESTORE EndSelect EndFunc My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator
greenmachine Posted January 27, 2006 Posted January 27, 2006 updated code as below, but still will not close... #include <GUIConstants.au3> #include <IE.au3> Opt("GUIOnEventMode", 1) HotKeySet("{ESC}", "Terminate") GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") GUICreate("TRANSPOWER - Induction, Stage 1 Welcome.",899, 674) Opt("ExpandVarStrings", 1) $oIE = ObjCreate("Shell.Explorer.2") $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 900,675) $oIE.navigate("@ScriptDir@\test.html") $oIE.document.body.scroll = "no" $oIE = 0 GUISetState() While 1 Sleep(1000) Wend Func Terminate() Exit 0 EndFunc Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Exit 0 Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE Case @GUI_CtrlId = $GUI_EVENT_RESTORE EndSelect EndFunc Minimize and restore will work regardless of whether you have the GUI events for them or not. Your problem is that you declare the events before you declare the GUI window the event is triggered from. Change it to this and you'll be fine: #include <GUIConstants.au3> #include <IE.au3> Opt("GUIOnEventMode", 1) HotKeySet("{ESC}", "Terminate") $GUIWindow = GUICreate("TRANSPOWER - Induction, Stage 1 Welcome.",899, 674) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") Opt("ExpandVarStrings", 1) $oIE = ObjCreate("Shell.Explorer.2") $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 900,675) $oIE.navigate("@ScriptDir@\test.html") $oIE.document.body.scroll = "no" $oIE = 0 GUISetState() While 1 Sleep(1000) Wend Func Terminate() Exit 0 EndFunc Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Exit 0 EndSelect EndFunc Now, whenever you declare a GUI event, it must go AFTER the window or control that goes with the event.
eJan Posted January 27, 2006 Posted January 27, 2006 Try with few lines less #include <GUIConstants.au3> #include <IE.au3> HotKeySet("{ESC}", "Terminate") GUICreate("TRANSPOWER - Induction, Stage 1 Welcome.",899, 674) Opt("ExpandVarStrings", 1) $oIE = ObjCreate("Shell.Explorer.2") $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 900,675) $oIE.navigate("@ScriptDir@\test.html") $oIE.document.body.scroll = "no" $oIE = 0 GUISetState() Func Terminate() Exit 0 EndFunc While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit Wend
cyanidemonkey Posted January 27, 2006 Author Posted January 27, 2006 (edited) ahhhh, thanks eJan BTW - your avatar - Kraftwerks' AutoBahn, cool album. Edited January 27, 2006 by cyanidemonkey My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator
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