找回密码
 加入
搜索
查看: 1281|回复: 2

求助把类似于游戏菜单分2个框运行方法

[复制链接]
发表于 2009-11-29 19:36:17 | 显示全部楼层 |阅读模式
本帖最后由 那片叶子 于 2009-11-29 22:37 编辑

http://www.autoitx.com/forum.php ... hlight=%B2%CB%B5%A5
如图:我显示成了2个,可是运行我只能运行第一个!附上附件,请各位帮忙两边都可以运行!

附件贴上


表达不清望见谅!

本帖子中包含更多资源

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

×

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2009-11-29 21:47:47 | 显示全部楼层
本帖最后由 afan 于 2009-11-29 21:50 编辑

修改掉了LZ那段 WM_NOTIFY 函数,解决LZ提出的问题就行了,未对其它代码修改~
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;class;;QQ150401022
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#NoTrayIcon
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Dim $Form1_1, $ListView1, $nMsg, $g_szVersion, $ListView1context, $ListView2
$g_szVersion = "myscript"
If WinExists($g_szVersion) Then Exit
AutoItWinSetTitle($g_szVersion)
_Gui()

GUICtrlSetStyle($ListView1, $LVS_ICON)
GUICtrlSetStyle($ListView2, $LVS_ICON)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

Func _Gui() ;窗体开始
        $Form1_1 = GUICreate("菜单", 782, 560, 192, 114, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS))
        $ListView1 = GUICtrlCreateListView("", 0, 0, 400, 559)
        $ListView2 = GUICtrlCreateListView("", 410, 0, 400, 559)
        GUISetState(@SW_SHOW)
EndFunc   ;==>_Gui

_Load();读取配置菜单参数
_Message();用来调用按钮参数,开始
Func _Message()
        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                Exit
                EndSwitch
        WEnd
EndFunc   ;==>_Message

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func _Load();读取配置参数,开始
        Local $hImage, $var, $i, $path, $error, $hFile
        If 0 = FileExists(@ScriptDir & "\game.ini") Then ;检测文件是否存在
                $hFile = DllCall("kernel32.dll", "Int", "_lcreat", "str", @ScriptDir & "\game.ini", "Int", 0);调用指定DLL
                DllCall("kernel32.dll", "Int", "_lclose", "Int", $hFile);调用指定DLL
                Exit;终止脚本运行
        EndIf
        $hImage = _GUIImageList_Create(32, 32, 5, 1) ;图标显示大小
        $var = IniReadSectionNames(@ScriptDir & "\game.ini") ;读取文件信息
        If @error Then ;这段应该是判断文件是否有内容
                MsgBox(4096, "提示", "请查看INI文件")
        Else;判断结束
                For $i = 1 To $var[0]
                        $path = IniRead(@ScriptDir & "\game.ini", String($var[$i]), "path", "");读取配置
                        If FileExists($path) Then;检查路径是否正确
                                _GUIImageList_AddIcon($hImage, $path, 0, True) ;$himage为包含所需图像的图标
                                _GUICtrlListView_InsertItem($ListView1, $var[$i], -1, $i - 1) ;列表的末尾添加一个新的项目
                        Else
                                MsgBox(0, "警警!!", "ini文件有误");路径不正确时提示
                                Exit
                        EndIf
                Next
                _GUICtrlListView_SetImageList($ListView1, $hImage, 0);将控件的图像列表
        EndIf
        Local $hImage1, $var1, $path1, $error1, $hFile1
        If 0 = FileExists(@ScriptDir & "\game1.ini") Then ;检测文件是否存在
                $hFile1 = DllCall("kernel32.dll", "Int", "_lcreat", "str", @ScriptDir & "\game1.ini", "Int", 0);调用指定DLL
                DllCall("kernel32.dll", "Int", "_lclose", "Int", $hFile1);调用指定DLL
                Exit;终止脚本运行
        EndIf
        $hImage1 = _GUIImageList_Create(32, 32, 5, 1) ;图标显示大小
        $var1 = IniReadSectionNames(@ScriptDir & "\game1.ini") ;读取文件信息
        If @error Then ;这段应该是判断文件是否有内容
                MsgBox(4096, "提示", "请查看INI文件")
        Else;判断结束
                For $i = 1 To $var1[0]
                        $path1 = IniRead(@ScriptDir & "\game1.ini", String($var1[$i]), "path", "");读取配置
                        If FileExists($path1) Then;检查路径是否正确
                                _GUIImageList_AddIcon($hImage1, $path1, 0, True) ;$himage为包含所需图像的图标
                                _GUICtrlListView_InsertItem($ListView2, $var1[$i], -1, $i - 1) ;列表的末尾添加一个新的项目
                        Else
                                MsgBox(0, "警警!!", "ini文件有误");路径不正确时提示
                                Exit
                        EndIf
                Next
                _GUICtrlListView_SetImageList($ListView2, $hImage1, 0);将控件的图像列表
        EndIf
EndFunc   ;==>_Load
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func WM_NOTIFY($hWnd, $message, $wParam, $sParam)
        Local $tNMHDR, $hWndFrom, $code
        $tNMHDR = DllStructCreate($tagNMHDR, $sParam)
        $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
        $code = DllStructGetData($tNMHDR, "code")
        If $code = $NM_DBLCLK Then
                If $hWndFrom = GUICtrlGetHandle($ListView1) Then zxrun($ListView1)
                If $hWndFrom = GUICtrlGetHandle($ListView2) Then zxrun($ListView2)
        EndIf
EndFunc   ;==>WM_NOTIFY
Func zxrun($ListView)
        Local $index, $text, $path
        $index = _GUICtrlListView_GetSelectedIndices($ListView);检索的选定项的索引
        $text = _GUICtrlListView_GetItemText($ListView, Int($index));返回一项或子项的文本
        $path = IniRead(@ScriptDir & "\game1.ini", String($text), "path", "");读取文本
        If $path <> '' Then ;判断内容是否大于或小于$path值
                ShellExecute($path);执行路径指向的程序,
        Else
                MsgBox(0, "警告!", $text & " 路径不在ini列表中,请和管理员联系");如果Path值等于的话就提示文件出错
        EndIf
EndFunc   ;==>zx
 楼主| 发表于 2009-11-29 22:37:14 | 显示全部楼层
谢谢afan ,本人笨拙!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-17 12:21 , Processed in 0.075381 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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