Sign in to follow this  
Followers 0
maniootek

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

9 posts in this topic

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.

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

YES! That's it ! That is exactly what I meant! Thank you.

@ Authenticity - that's enough

@ KaFu - it's good advice for future, thanks too

Edited by maniootek

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

#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

Share this post


Link to post
Share on other sites

Heh KaFu. So add the necessary logic. :)

I knew you would reply with a workaround for the workaround :)...tried that too, but I found it not 100% reliable...

Share this post


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
Sign in to follow this  
Followers 0