maniootek Posted October 21, 2009 Share Posted October 21, 2009 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 More sharing options...
Authenticity Posted October 21, 2009 Share Posted October 21, 2009 (edited) #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) ;... GUISetOnEvent($GUI_EVENT_CLOSE, "_Close") ;... While 1 Sleep(20) ; Process something while the program is running. WEnd ;... Func _Close() GUIDelete() Exit EndFunc Edited October 21, 2009 by Authenticity Link to comment Share on other sites More sharing options...
KaFu Posted October 21, 2009 Share Posted October 21, 2009 (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 October 21, 2009 by KaFu AnonymousX 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
maniootek Posted October 21, 2009 Author Share Posted October 21, 2009 (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 October 21, 2009 by maniootek Link to comment Share on other sites More sharing options...
Authenticity Posted October 21, 2009 Share Posted October 21, 2009 #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 More sharing options...
KaFu Posted October 21, 2009 Share Posted October 21, 2009 HotKeySet('{ESC}', '_Close') consums the ESC key for other applications too... and I quiet often hit it ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Authenticity Posted October 21, 2009 Share Posted October 21, 2009 (edited) Heh KaFu. So add the necessary logic. Edit:Func _Close() If WinGetHandle('') <> $hGUI Then HotKeySet('{ESC}') Send('{ESC}') HotKeySet('{ESC}', '_Close') Return EndIf GUIDelete() Exit EndFunc ;==>_Close Edited October 21, 2009 by Authenticity Link to comment Share on other sites More sharing options...
maniootek Posted October 21, 2009 Author Share Posted October 21, 2009 (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 October 21, 2009 by maniootek Link to comment Share on other sites More sharing options...
KaFu Posted October 21, 2009 Share Posted October 21, 2009 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... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now