texan Posted May 8, 2015 Posted May 8, 2015 #include <GuiConstantsEx.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode OnAutoItExitRegister("OnExit") GUISetOnEvent($GUI_EVENT_CLOSE, "OnExitScript") GUICreate("This is a test", 500, 500) $ExitButton = GUICtrlCreateButton("Exit", 400, 400, 80, 24) GUICtrlSetOnEvent($ExitButton, "OnExitScript") GuiSetState() While 1 Sleep(1000) WEnd ;End of main script ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Func OnExitScript() MsgBox(1,"test", "OnExitScript") Exit EndFunc Func OnExit() MsgBox(1,"test", "OnExit") EndFuncMy GUI window will not close when I click the X in the top right of the window or when I try using Alt+F4. I have stripped this code down to the bare minimum for my example but the above code shows a window with a single Exit button. The button works but not the X in top right. I give up, what obvious simple thing am I overlooking?
texan Posted May 8, 2015 Author Posted May 8, 2015 Ugggg!!! finally figured it out. You can NOT perform GUISetOnEvent($GUI_EVENT_CLOSE, "OnExitScript") BEFORE you create the GUI. Moved that line below GUICreate and it worked.Damn I spent forever trying to figure that out!!!
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