找回密码
 加入
搜索
查看: 5554|回复: 16

[AU3基础] 【已解决】 求助 点击按钮控件后,主菜单不退出的,解决办法!

[复制链接]
发表于 2015-11-22 16:54:25 | 显示全部楼层 |阅读模式
本帖最后由 franly 于 2015-11-22 23:09 编辑

点击菜单中的,按钮后,主菜单就退出了!怎么解决,让菜单常在,直到我们自己手动关!
分享个菜单!
代码如下:
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Icon=D:\autoit3\Aut2Exe\Icons\favicon.ico
#PRE_Outfile=MINI菜单.exe
#PRE_Compression=4
#PRE_Res_Comment=MINI菜单
#PRE_Res_Description=MINI菜单
#PRE_Res_Fileversion=1.0.0.0
#PRE_Res_LegalCopyright=by MINI菜单
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>
If Not FileExists("menu.ini") Then
IniWrite("menu.ini","title","title","软件菜单")
IniWrite("menu.ini","command","菜单名称1","路径1")
IniWrite("menu.ini","command","菜单名称2","路径2")
IniWrite("menu.ini","command","菜单名称3","路径3")
IniWrite("menu.ini","command","菜单名称4","路径4")
IniWrite("menu.ini","command","以此类推","有多少写多少,最多不超20个为宜")
EndIf
Global $Form
Opt("GUIOnEventMode", 1)
$Command = IniReadSection("menu.ini", "command")
$title=IniRead("menu.ini","title","title","")
$height2=$Command[0][0]*45
$Form1 = GUICreate($title, 150, $height2+20, -1, -1,BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
For $I = 1 To $Command[0][0]
    $Command[$i][0] = GUICtrlCreateButton($Command[$i][0], 16, 16+($i-1)*45, 123, 40)
        $img= _GUIImageList_Create(32, 32, 5, 1, 0)
    _GUIImageList_AddIcon($img, $Command[$I][1], 0, True)
    _GUICtrlButton_SetImageList(-1, $img)
        GUICtrlSetOnEvent($Command[$I][0], "Command")
Next
;DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 1000, "long", 0x00080000)
GUISetState()
While 1
    Sleep(1000)
WEnd
Func Command()
    For $i = 1 To UBound($Command, 1) - 1
               If @GUI_CtrlId = $Command[$I][0] Then Run($Command[$I][1],StringLeft ( $Command[$I][1], StringInStr($Command[$I][1], "\",0,-1)))
    Next
   _exit()
EndFunc
Func _Exit()
    ;DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 1000, "long", 0x00090000);渐隐
;DllCall($dll, "int:cdecl", "DeInitDecoration")
    ;DllCall($dll, "int:cdecl", "RemoveSkin")
    ;DllClose($dll)
    ;FileDelete(@TempDir&"\SkinCrafterDll.dll")
    ;FileDelete(@TempDir&"\skin.skf")
        Exit
EndFunc
发表于 2015-11-22 17:04:09 | 显示全部楼层
;_exit()
 楼主| 发表于 2015-11-22 17:08:32 | 显示全部楼层
在那里加,请教2楼,求解
 楼主| 发表于 2015-11-22 17:17:43 | 显示全部楼层
急,求解呀!大神们,请指教哟!
发表于 2015-11-22 17:34:31 | 显示全部楼层
回复 3# franly


    发帖不按规范,代码不用代码标签,我如何指出哪一行?
 楼主| 发表于 2015-11-22 17:40:13 | 显示全部楼层
回复 5# afan
 楼主| 发表于 2015-11-22 17:40:28 | 显示全部楼层
怎么标签?
发表于 2015-11-22 18:00:24 | 显示全部楼层
发表于 2015-11-22 18:43:59 | 显示全部楼层


可以删除,也可以加分号注释掉

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2015-11-22 19:48:01 | 显示全部楼层
回复 9# fuldho 删除了,和加了分号都不行呀!
 楼主| 发表于 2015-11-22 19:59:13 | 显示全部楼层
回复 8# afan 版主求解呀!
发表于 2015-11-22 21:44:50 | 显示全部楼层
本帖最后由 afan 于 2015-11-22 21:48 编辑

回复 11# franly


    因为你不愿编辑帖子,9#的坛友只能给你上贴图说明了…
[ code]你的代码[/ code] (删除标签空格)加代码标签就这么难吗?
既然你照他说的也没用,那就没办法了。
发表于 2015-11-22 22:10:21 | 显示全部楼层
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Icon=D:\autoit3\Aut2Exe\Icons\favicon.ico
#PRE_Outfile=MINI菜单.exe
#PRE_Compression=4
#PRE_Res_Comment=MINI菜单
#PRE_Res_Description=MINI菜单
#PRE_Res_Fileversion=1.0.0.0
#PRE_Res_LegalCopyright=by MINI菜单
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>
If Not FileExists("menu.ini") Then
        IniWrite("menu.ini", "title", "title", "软件菜单")
        IniWrite("menu.ini", "command", "菜单名称1", "路径1")
        IniWrite("menu.ini", "command", "菜单名称2", "路径2")
        IniWrite("menu.ini", "command", "菜单名称3", "路径3")
        IniWrite("menu.ini", "command", "菜单名称4", "路径4")
        IniWrite("menu.ini", "command", "以此类推", "有多少写多少,最多不超20个为宜")
EndIf
Global $Form
Opt("GUIOnEventMode", 1)
$Command = IniReadSection("menu.ini", "command")
$title = IniRead("menu.ini", "title", "title", "")
$height2 = $Command[0][0] * 45
$Form1 = GUICreate($title, 150, $height2 + 20, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
For $I = 1 To $Command[0][0]
        $Command[$I][0] = GUICtrlCreateButton($Command[$I][0], 16, 16 + ($I - 1) * 45, 123, 40)
        $img = _GUIImageList_Create(32, 32, 5, 1, 0)
        _GUIImageList_AddIcon($img, $Command[$I][1], 0, True)
        _GUICtrlButton_SetImageList(-1, $img)
        GUICtrlSetOnEvent($Command[$I][0], "Command")
Next
;DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 1000, "long", 0x00080000)
GUISetState()
While 1
        Sleep(1000)
WEnd
Func Command()
        For $I = 1 To UBound($Command, 1) - 1
                If @GUI_CtrlId = $Command[$I][0] Then Run($Command[$I][1], StringLeft($Command[$I][1], StringInStr($Command[$I][1], "", 0, -1)))
        Next
        _exit()
EndFunc   ;==>Command
Func _Exit()
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 1000, "long", 0x00090000);渐隐
        DllCall($dll, "int:cdecl", "DeInitDecoration")
        DllCall($dll, "int:cdecl", "RemoveSkin")
        DllClose($dll)
        FileDelete(@TempDir & "\SkinCrafterDll.dll")
        FileDelete(@TempDir & "\skin.skf")
        Exit
EndFunc   ;==>_Exit
新手嘛,要多泡论坛哟。
发表于 2015-11-22 22:10:33 | 显示全部楼层
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Icon=D:\autoit3\Aut2Exe\Icons\favicon.ico
#PRE_Outfile=MINI菜单.exe
#PRE_Compression=4
#PRE_Res_Comment=MINI菜单
#PRE_Res_Description=MINI菜单
#PRE_Res_Fileversion=1.0.0.0
#PRE_Res_LegalCopyright=by MINI菜单
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>
If Not FileExists("menu.ini") Then
        IniWrite("menu.ini", "title", "title", "软件菜单")
        IniWrite("menu.ini", "command", "菜单名称1", "路径1")
        IniWrite("menu.ini", "command", "菜单名称2", "路径2")
        IniWrite("menu.ini", "command", "菜单名称3", "路径3")
        IniWrite("menu.ini", "command", "菜单名称4", "路径4")
        IniWrite("menu.ini", "command", "以此类推", "有多少写多少,最多不超20个为宜")
EndIf
Global $Form
Opt("GUIOnEventMode", 1)
$Command = IniReadSection("menu.ini", "command")
$title = IniRead("menu.ini", "title", "title", "")
$height2 = $Command[0][0] * 45
$Form1 = GUICreate($title, 150, $height2 + 20, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
For $I = 1 To $Command[0][0]
        $Command[$I][0] = GUICtrlCreateButton($Command[$I][0], 16, 16 + ($I - 1) * 45, 123, 40)
        $img = _GUIImageList_Create(32, 32, 5, 1, 0)
        _GUIImageList_AddIcon($img, $Command[$I][1], 0, True)
        _GUICtrlButton_SetImageList(-1, $img)
        GUICtrlSetOnEvent($Command[$I][0], "Command")
Next
;DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 1000, "long", 0x00080000)
GUISetState()
While 1
        Sleep(1000)
WEnd
Func Command()
        For $I = 1 To UBound($Command, 1) - 1
                If @GUI_CtrlId = $Command[$I][0] Then Run($Command[$I][1], StringLeft($Command[$I][1], StringInStr($Command[$I][1], "", 0, -1)))
        Next
        _exit()
EndFunc   ;==>Command
Func _Exit()
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 1000, "long", 0x00090000);渐隐
        DllCall($dll, "int:cdecl", "DeInitDecoration")
        DllCall($dll, "int:cdecl", "RemoveSkin")
        DllClose($dll)
        FileDelete(@TempDir & "\SkinCrafterDll.dll")
        FileDelete(@TempDir & "\skin.skf")
        Exit
EndFunc   ;==>_Exit
新手嘛,要多泡论坛哟。
 楼主| 发表于 2015-11-22 22:40:42 | 显示全部楼层
回复 14# lpxx 大神用你的代码,还是主菜单退出哟!怎么回事?求解
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-3-29 09:02 , Processed in 0.079527 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表