помогите
написал тут код ,Но есть проблема
Я могу закрит иконку ,толко нажав ESC или Enter что надо даписат что бы иконка закривалас при нажатии мышки на нее?
TEMP = дорожка к *.png($temp = "E:\VBA\AutoIt\GUI\1.png" )
Код:

#NoTrayIcon
#include <GDIPlus.au3>; this is where the magic happens, people
#include <GuiComboBox.au3>
#include <File.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WinAPI.au3>
Global Const $AC_SRC_ALPHA = 1, $ULW_ALPHA = 2
Global $launchDir = @DesktopDir, $GUI
;~ Dim $temp1
$temp = "E:\VBA\AutoIt\GUI\1.png"
Transp_PNG($temp)
Func Transp_PNG($temp, $iOpacity = 255, $EnableFade = True)
If $iOpacity < 0 Then $iOpacity = 0
If $iOpacity > 255 Then $iOpacity = 255
; Load PNG file as GDI bitmap
_GDIPlus_Startup()
$pngSrc = $temp
$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)
; Extract image width and height from PNG
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)
; Create layered window
$GUI = GUICreate("lod3n launcher", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState()
WinSetOnTop($GUI, "", 1)
If $EnableFade Then
;fade in png background
For $i = 0 To $iOpacity Step 1
SetBitmap($GUI, $hImage, $i)
Next
Else
SetBitmap($GUI, $hImage, $iOpacity)
EndIf
; set default button for Enter key activation - renders outside GUI window
$BtnExit = GUICtrlCreateButton("Exit", $width, $height, 10, 10, $BS_DEFPUSHBUTTON)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $BtnExit
ExitLoop
EndSwitch
WEnd
If $EnableFade Then
;fade out png background
For $i = $iOpacity To 0 Step -1
SetBitmap($GUI, $hImage, $i)
Next
Else
SetBitmap($GUI, $hImage, 0)
EndIf
EndFunc ;==>Transp_PNG
Func CancelPressed()
Exit
EndFunc
; ====================================================================================================
; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ====================================================================================================
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST
; ====================================================================================================
; SetBitMap
; ====================================================================================================
Func SetBitmap($hGUI, $hImage, $iOpacity)
Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
$hScrDC = _WinAPI_GetDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", $iOpacity)
DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
_WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
_WinAPI_ReleaseDC(0, $hScrDC)
_WinAPI_SelectObject($hMemDC, $hOld)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteDC($hMemDC)
EndFunc ;==>SetBitmap