Jump to content

Recommended Posts

Posted

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.

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

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

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

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