Opened 14 years ago
Closed 14 years ago
#1794 closed Bug (No Bug)
Opt("GuiCloseOnESC", 0) causes WinClose() to be ignored
Reported by: | AndyS01@… | Owned by: | |
---|---|---|---|
Milestone: | Component: | AutoIt | |
Version: | 3.3.6.1 | Severity: | None |
Keywords: | GuiCloseOnESC, WinCLose(), WinKill() | Cc: |
Description
When a script is compiled with Opt("GuiCloseOnESC", 0) active, another script, after getting its handle cannot close the first script. The WinClose() returns an OK status, but it really doesn't work. Compiling the first script with Opt("GuiCloseOnESC", 1) avtive works OK.
To reproduce: compile the test script, below; open a DOS window; run the compiled script; run the compiled script again. This time, there will be an error MsgBox complaining that the instance was not killed.
Change Opt("GuiCloseOnESC", 0) to Opt("GuiCloseOnESC", 1) and run the reproduce steps again. This time it works OK.
Test script:
#include <GuiConstantsEx.au3> #include <GuiListView.au3> [b]Opt("GuiCloseOnESC", 0)[/b] Global $sCurrentTitle = "Test WinClose()" runUnique() ; Kill off any currently running version of this script $hGUI = GUICreate($sCurrentTitle, 300, 200) $hListView = _GUICtrlListView_Create($hGUI, "Items|SubItems", 2, 2, 296, 196, $LVS_REPORT) For $i = 1 To 10 _GUICtrlListView_AddItem($hListView, @HOUR & ":" & @MIN & ":" & @SEC & " - " & $i) _GUICtrlListView_AddSubItem($hListView, $i - 1, "SubItem " & $i, 1) Next GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE exit (1) Func runUnique() Local $hWnd, $res, $title = $sCurrentTitle if (WinActivate($title, "") <> 0) Then $hWnd = WinGetHandle($title, "") If (Not IsHWnd($hWnd)) Then $hWnd = HWnd($hWnd) if (IsHWnd($hWnd)) Then $res = WinClose($hWnd) if ($res == 0) Then ConsoleWrite("+++: WinClose() failed") $res = WinKill($hWnd) ConsoleWrite("+++: WinKill() returned " & $res & @CRLF) if ($res == 0) Then ConsoleWrite("+++: WinKill() failed") EndIf EndIf if (WinActivate($title, "") <> 0) Then MsgBox(0, "ERROR", "Cannot kill window") Else MsgBox(0, "INFO", "Killed other window") EndIf Else MsgBox(0, "ERROR", "Cannot get win handle") EndIf EndIf EndFunc ;==>runUnique
Attachments (0)
Change History (4)
comment:1 Changed 14 years ago by MrCreatoR <mscreator@…>
comment:2 Changed 14 years ago by MrCreatoR <mscreator@…>
I think it's a problem in the option name/description, it should be something like this:
Opt("GUIClose", 0)
Because it's blocking the window from been closed by external application. Althought it could be handy, and we can always use GUISetAccelerators to prevent GUI closing by ESC.
comment:3 Changed 14 years ago by BrewmanNH
I also found out that you can't TaskKill the program from a command line unless you use the /f (Force terminate) command line switch with taskkill if the script includes the Opt("GUICloseOnESC", 0) option.
comment:4 Changed 14 years ago by Jon
- Resolution set to No Bug
- Status changed from new to closed
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Too much complicated, here is a more simple reproducing script:
no need to compile or anything else, just run the script twice, it should close the previous GUI, but it doesn't. BTW, it's only with AutoIt GUI, other winows closing fine.