Jump to content

$GUI_EVENT_CLOSE does not work


Chorda
 Share

Recommended Posts

Hi,

I'm trying to close a window using the $GUI_EVENT_CLOSE, but it does not close. Here is my code:

CODE
#include <GUIConstants.au3>

#include <GUIConstantsEx.au3>

GUICreate("Hello World", 200, 100)

Opt("GUIEventOptions",1)

GUISetState(@SW_SHOW)

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

;HotKeySet('{esc}', 'CLOSEClicked') ;Press the Esc key to exit out

Opt("GUICloseOnESC",1)

Sleep(2000)

Func CLOSEClicked()

Exit

EndFunc

Further, when I use Opt("GUICloseOnESC",1) it does not close, but when I use HotKeySet('{esc}', 'CLOSEClicked') , then it closes.

So it seems to me that the $GUI_EVENT_CLOSE does not do its job.

Any idea?

Thanks

Link to comment
Share on other sites

There's not a problem with the windows message,there's a problem with your code. There was a topic earlier today that I helped with that had the same problem. In fact it's ~11 topics down from this one at the time of my post.

http://www.autoitscript.com/forum/index.php?showtopic=82765

Edited by dbzfanatic
Link to comment
Share on other sites

Not really a solution for his problem ...

The problem in your script is that you don't have Opt("GUIOnEventMode",1) - that confuses the GUI and that's the reason it doesn't work.

This works perfect:

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>

GUICreate("Hello World", 200, 100)
Opt("GUIOnEventMode",1)     ;changed your line with this
;you can add Opt("GUIEventOptions",1) if you need it and it willl work
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
;HotKeySet('{esc}', 'CLOSEClicked') ;Press the Esc key to exit out
Opt("GUICloseOnESC",1)
Sleep(2000)

Func CLOSEClicked()
Exit
EndFunc

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...