Jump to content

Close gui window immediately when you click on "X"-button


Recommended Posts

I know there's alot answers in search results but I can't find that properly one which may solve my problem. Is it possible to close gui window immediately when user click on "x" (exit) button and no matter what was currently processed? I hope you got my point.

Link to comment
Share on other sites

Solution above will not exit immediately, if currently an onevent mode function is being processed, but will close after the function return...

#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)

GUICreate("My GUI") ; will create a dialog box that when displayed is centered
GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")
GUICtrlCreateButton("Trigger long running function...",10,10,200)
GUICtrlSetOnEvent(-1,"_sleep")
GUISetState(@SW_SHOW) ; will display an empty dialog box

While 1
  Sleep(20)
WEnd

func _sleep()
    sleep(5000)
EndFunc

Func _Close()
  GUIDelete()
  Exit
EndFunc

This one will...

http://www.autoitscript.com/forum/index.php?showtopic=96829&view=findpost&p=698605

Edited by KaFu
Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
HotKeySet('{ESC}', '_Close')
Opt("GUIOnEventMode", 1)

GUICreate("My GUI") ; will create a dialog box that when displayed is centered
GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")
GUICtrlCreateButton("Trigger long running function...",10,10,200)
GUICtrlSetOnEvent(-1,"_sleep")
GUISetState(@SW_SHOW) ; will display an empty dialog box

While 1
  Sleep(20)
WEnd

func _sleep()
    sleep(5000)
EndFunc

Func _Close()
  GUIDelete()
  Exit
EndFunc

Workaround...

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
HotKeySet('{ESC}', '_Close')
Opt("GUIOnEventMode", 1)

GUICreate("My GUI") ; will create a dialog box that when displayed is centered
GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")
GUICtrlCreateButton("Trigger long running function...",10,10,200)
GUICtrlSetOnEvent(-1,"_sleep")
GUISetState(@SW_SHOW) ; will display an empty dialog box

While 1
  Sleep(20)
WEnd

func _sleep()
    sleep(5000)
EndFunc

Func _Close()
  GUIDelete()
  Exit
EndFunc

Workaround...

nope, for me doesn't when first I click on gui button then I try close via X button

added:

but esc button works good

Edited by maniootek
Link to comment
Share on other sites

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