xwlzx 发表于 2010-3-15 20:29:04

关闭程序后托盘图标还在,需鼠标移向托盘图标才令图标消失-求助

本帖最后由 xwlzx 于 2010-3-15 20:31 编辑

关闭程序后托盘图标还在,需鼠标移向图标才令图标消失-求助,请高手帮助找出问题的原因#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=exec.ico
#AutoIt3Wrapper_outfile=AutoIt3控制中心.exe
#AutoIt3Wrapper_Res_Comment=AutoIt3控制中心
#AutoIt3Wrapper_Res_Description=DragonOnline
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=DragonOnline
#AutoIt3Wrapper_Res_Field=CompanyName|瑞安市第六中学
#AutoIt3Wrapper_Res_Field=OriginalFilename|AutoIt3Tools
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstants.au3>
#include <ButtonConstants.au3>
;#####################自定义托盘必需要这个UDF####################
#include "ModernMenuRaw.au3" ; 自定义托盘必需要这个UDF
;#include "ModernMenu.au3"
;##########################加载GUI皮肤############################
FileInstall("SkinCrafterDll.dll", @TempDir & "\SkinCrafterDll.dll", 1)
FileInstall("SkinCrafterDll.skf", @TempDir & "\SkinCrafterDll.skf", 1)
$Dll = DllOpen(@TempDir & "\SkinCrafterDll.dll")

;##############################################################
$Form1 = GUICreate("AutoIt3安装卸载程序", 235, 146, 462, 222)

;##########################调用GUI皮肤函数############################
_SkinGUI(@TempDir & "\SkinCrafterDll.dll", @TempDir & "\SkinCrafterDll.skf", $Form1)
;################################GUI控件##########################
$Group1 = GUICtrlCreateGroup("请选择相应要执行的项", 8, 8, 217, 129)
$GreenButton = GUICtrlCreateButton("绿化", 27, 40, 177, 33)
GUICtrlSetTip(-1, "关联相关文档并注册相关信息","提示",1)
$CleanButton = GUICtrlCreateButton("清除", 27, 88, 177, 33)
GUICtrlSetTip(-1, "去掉相关文联及注册信息","提示",1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

;##########################托盘菜单美化#########################
; *** Create the tray icon ***
$nTrayIcon1        = _TrayIconCreate(@ScriptName, @ScriptName, 0)
_TrayIconSetClick(-1, 16)
_TrayIconSetState( ) ; Show the tray icon
;_TrayIconSetState(@ScriptName,1); Hide the tray icon

; *** Create the tray context menu ***
$nTrayMenu1        = _TrayCreateContextMenu() ; is the same like _TrayCreateContextMenu(-1) or _TrayCreateContextMenu($nTrayIcon1)
$nSideItem3        = _CreateSideMenu($nTrayMenu1)
_SetSideMenuText($nSideItem3, "瑞中六中")
_SetSideMenuColor($nSideItem3, 0x00FFFF) ; yellow; default color - white
_SetSideMenuBkColor($nSideItem3, 0x802222) ; bottom start color - dark blue
_SetSideMenuBkGradColor($nSideItem3, 0x4477AA) ; top end color - orange
;_SetSideMenuImage($nSideItem3, "shell32.dll", 309, TRUE)

$TrayAbout = _TrayCreateItem("关于")
$Traymax = _TrayCreateItem("窗口")
_TrayCreateItem("")
_TrayItemSetIcon(-1, "", 0)
$TrayExit = _TrayCreateItem("退出")

_TrayItemSetIcon($TrayAbout, "shell32.dll", -24)
_TrayItemSetIcon($Traymax, "shell32.dll", -25)
_TrayItemSetIcon($TrayExit, "shell32.dll", -28)

GUICtrlSetState($TrayAbout, $GUI_DEFBUTTON)


; WM_MEASUREITEM and WM_DRAWITEM are registered in
; "ModernMenu.au3" so they don"t need to registered here
; Also OnAutoItExit() is in "ModernMenu.au3" to cleanup the
; menu imagelist and font
;######################主循环部分##################################
While 1
        $Msg = GUIGetMsg()
        Switch $Msg
                Case $GUI_EVENT_CLOSE
                        _TrayIconSetState(@ScriptName,1); Hide the tray icon
                        Quit()
                        Exit
                Case $GreenButton
                        RegWrite('HKEY_CLASSES_ROOT\.kxf\ShellNew')
            RegWrite('HKEY_CLASSES_ROOT\.kxf\ShellNew', 'FileName', 'REG_SZ', '' & @ScriptDir & '\Form.kxf')
                        FileInstall("Form.kxf", @ScriptDir & "\", 1)
                        DllCall("shell32.dll","none","SHChangeNotify","long",0x8000000,"int",0,"ptr",0,"ptr", 0)
                        Run(@ScriptDir & "\au3tool.exe /s")
                Case $CleanButton
                        Run(@ScriptDir & "\au3tool.exe /u")
                        TrayTip("完成", "设置应用成功", 5, 1)
            Sleep(900)
                        TrayTip("清除所有的气球提示","",0)
                Case $TrayExit
                        _TrayIconSetState(@ScriptName,1); Hide the tray icon
                        Quit()
                        ExitLoop
                Case $TrayAbout
                        Msgbox(64,"关于","许文龙 2010年制于瑞安市第六中学")
                Case $Traymax
                        WinSetState("AutoIt3安装卸载程序","",@SW_RESTORE)
        EndSwitch
WEnd
_TrayIconDelete($nTrayIcon1)
Exit

;##################定义皮肤函数##################
Func _SkinGUI($SkincrafterDll, $SkincrafterSkin, $Handle)
        $Dll = DllOpen($SkincrafterDll)
        DllCall($Dll, "int:cdecl", "InitLicenKeys", "wstr", "1", "wstr", "", "wstr", "1@1.com", "wstr", "1")
        DllCall($Dll, "int:cdecl", "InitDecoration", "int", 1)
        DllCall($Dll, "int:cdecl", "LoadSkinFromFile", "wstr", $SkincrafterSkin)
        DllCall($Dll, "int:cdecl", "DecorateAs", "int", $Handle, "int", 25)
        DllCall($Dll, "int:cdecl", "ApplySkin")
EndFunc   ;==>_SkinGUI

;##################皮肤退出##################
Func Quit()
        GUISetState(@SW_HIDE)
        DllCall($Dll, "int:cdecl", "DeInitDecoration")
        DllCall($Dll, "int:cdecl", "RemoveSkin")
        DllClose($Dll)
        FileDelete(@TempDir & "\SkinCrafterDll.dll")
        FileDelete(@TempDir & "\SkinCrafterDll.skf")
        ;FileDelete(@TempDir & "\top.jpg") ;删除临时文件夹里的图片
        Exit
EndFunc

xwlzx 发表于 2010-3-15 20:41:38

本帖最后由 xwlzx 于 2010-3-15 20:45 编辑

终于找到原因了!将主循环部分;######################主循环部分##################################

While 1

      $Msg = GUIGetMsg()

      Switch $Msg

                Case $GUI_EVENT_CLOSE

                        _TrayIconSetState(@ScriptName,1); Hide the tray icon

                        Quit()

                        Exit

                Case $GreenButton

                        RegWrite('HKEY_CLASSES_ROOT\.kxf\ShellNew')

                        RegWrite('HKEY_CLASSES_ROOT\.kxf\ShellNew', 'FileName', 'REG_SZ', '' & @ScriptDir & '\Form.kxf')

                        FileInstall("Form.kxf", @ScriptDir & "\", 1)

                        DllCall("shell32.dll","none","SHChangeNotify","long",0x8000000,"int",0,"ptr",0,"ptr", 0)

                        Run(@ScriptDir & "\au3tool.exe /s")

                Case $CleanButton

                        Run(@ScriptDir & "\au3tool.exe /u")

                        TrayTip("完成", "设置应用成功", 5, 1)

                        Sleep(900)

                        TrayTip("清除所有的气球提示","",0)

                Case $TrayExit

                        _TrayIconSetState(@ScriptName,1); Hide the tray icon

                        Quit()

                        ExitLoop

                Case $TrayAbout

                        Msgbox(64,"关于","许文龙 2010年制于瑞安市第六中学")

                Case $Traymax

                        WinSetState("AutoIt3安装卸载程序","",@SW_RESTORE)

      EndSwitch

WEnd

_TrayIconDelete($nTrayIcon1)

Exit

改成如下所就行了;######################主循环部分##################################

While 1

      $Msg = GUIGetMsg()

      Switch $Msg

                Case $GUI_EVENT_CLOSE

                        _TrayIconDelete($nTrayIcon1)

                        Quit()

                        Exit

                Case $GreenButton

                        RegWrite('HKEY_CLASSES_ROOT\.kxf\ShellNew')

                        RegWrite('HKEY_CLASSES_ROOT\.kxf\ShellNew', 'FileName', 'REG_SZ', '' & @ScriptDir & '\Form.kxf')

                        FileInstall("Form.kxf", @ScriptDir & "\", 1)

                        DllCall("shell32.dll","none","SHChangeNotify","long",0x8000000,"int",0,"ptr",0,"ptr", 0)

                        Run(@ScriptDir & "\au3tool.exe /s")

                Case $CleanButton

                        Run(@ScriptDir & "\au3tool.exe /u")

                        TrayTip("完成", "设置应用成功", 5, 1)

                        Sleep(900)

                        TrayTip("清除所有的气球提示","",0)

                Case $TrayExit

                     _TrayIconDelete($nTrayIcon1)
                        Quit()

                        ExitLoop

                Case $TrayAbout

                        Msgbox(64,"关于","许文龙 2010年制于瑞安市第六中学")

                Case $Traymax

                        WinSetState("AutoIt3安装卸载程序","",@SW_RESTORE)

      EndSwitch

WEnd
Exit

页: [1]
查看完整版本: 关闭程序后托盘图标还在,需鼠标移向托盘图标才令图标消失-求助