﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
1794	"Opt(""GuiCloseOnESC"", 0) causes WinClose() to be ignored"	AndyS01@…		"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
}}}
"	Bug	closed		AutoIt	3.3.6.1	None	No Bug	GuiCloseOnESC, WinCLose(), WinKill()	
