Jump to content

Recommended Posts

#include <GuiConstantsEx.au3>

Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
GUISetOnEvent($GUI_EVENT_CLOSE, "OnExitScript")

GUICreate("This is a test", 500, 500)
$ExitButton = GUICtrlCreateButton("Exit", 400, 400, 80, 24)
GUICtrlSetOnEvent($ExitButton, "OnExitScript")

While 1
;End of main script

Func OnExitScript()
    MsgBox(1,"test", "OnExitScript")

Func OnExit()
    MsgBox(1,"test", "OnExit")

My 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?

Link to post
Share on other sites

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!!!

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...