mike2003 Posted July 11, 2018 Posted July 11, 2018 I want to close the script window with another script. But if I use Opt("GUICloseOnESC", 0) then the command WinClose does not work. WHY??? Simple test #NoTrayIcon Opt("GUICloseOnESC", 0) #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Scores", 615, 438, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 24, 8, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 WinClose("Scores") EndSwitch WEnd
Developers Jos Posted July 11, 2018 Developers Posted July 11, 2018 That seems to block the Close message totally, but you still can use GuiDelete($Form1) in stead of a WinClose() to close the window, which should be preferred anyway. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
mike2003 Posted July 11, 2018 Author Posted July 11, 2018 (edited) 3 hours ago, Jos said: you still can use GuiDelete($Form1) 3 hours ago, mike2003 said: with another script. This is an old bug. Anyway, I found a solution in the Russian forum.http://autoit-script.ru/index.php?topic=963.0GUIRegisterMsg($WM_CLOSE, "WM_CLOSE") #NoTrayIcon Opt("GUICloseOnESC", 0) #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Scores", 615, 438, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 24, 8, 75, 25) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_CLOSE, "WM_CLOSE") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 WinClose("Scores") EndSwitch WEnd Func WM_CLOSE($hWnd, $nMsg, $lParam, $wParam) Exit EndFunc Edited July 11, 2018 by mike2003
Developers Jos Posted July 11, 2018 Developers Posted July 11, 2018 "With another script " while the WinClose with its own Title is located in the same script? confusing for me. That solution indeed will work and don't think you need the WinKill() in there. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
mike2003 Posted July 11, 2018 Author Posted July 11, 2018 3 hours ago, Jos said: don't think you need the WinKill() in there. Yes, it's left here from previous tests.
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