找回密码
 加入
搜索
查看: 2128|回复: 4

[AU3基础] [已解决]二维数组怎么调用ini配置文件

[复制链接]
发表于 2016-9-26 15:20:05 | 显示全部楼层 |阅读模式
本帖最后由 梦倾天下 于 2016-9-27 15:16 编辑

怎么把按钮标题名字获取为name的值
把按钮点击的路径获取到path的值
标题我现在直接用的$type_link的值,我感觉不应该是这么做的
初学者,可能问题有点小白,拜托各位大神解惑~也试过for…to…next,没搞懂……
------------------------------------------------
$type_ini=@ScriptDir&"\ini\install.ini"
$type_link=IniReadSection($type_ini,"type")

$Button1 = GUICtrlCreateButton($type_link[1][1], 15, 32, 100, 33)
$button2 = GUICtrlCreateButton($type_link[2][1], 129, 32, 100, 33)
$Button3 = GUICtrlCreateButton($type_link[3][1], 15, 78, 100, 33)

Case $Button1
                run("获取到path的值")
Case $Button2
                
Case $Button3
-------------------------------
install.ini文件内容为:
[type]
1=酷我音乐
2=QQ影音
3=腾讯QT

[酷我音乐]
name=酷我音乐
path=D:\software\酷我音乐.exe

[QQ影音]
name=QQ影音
path=D:\software\QQ影音.exe

[腾讯QT]
name=腾讯QT
path=D:\software\腾讯QT.exe
---------------------------
按钮数量不变,就名称和软件安装路径会变,所以希望通过直接修改ini来更改
发表于 2016-9-26 19:07:22 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$type_ini= @ScriptDir & "\ini\install.ini"
$type_link=IniReadSection($type_ini,"type")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 458, 280, 192, 124)
$Button1 = GUICtrlCreateButton($type_link[1][1], 15, 32, 100, 33)
$button2 = GUICtrlCreateButton($type_link[2][1], 129, 32, 100, 33)
$Button3 = GUICtrlCreateButton($type_link[3][1], 15, 78, 100, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$binary_file = ""
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $binary_file = IniRead($type_ini, GUICtrlRead($Button1), "path", "")
                        Run($binary_file)
                        If @error Then
                                MsgBox(0, "无法执行", "不存在:" & $binary_file)
                        EndIf
                Case $Button2
                        $binary_file = IniRead($type_ini, GUICtrlRead($Button2), "path", "")
                        Run($binary_file)
                        If @error Then
                                MsgBox(0, "无法执行", "不存在:" & $binary_file)
                        EndIf
                Case $Button3
                        $binary_file = IniRead($type_ini, GUICtrlRead($Button3), "path", "")
                        Run($binary_file)
                        If @error Then
                                MsgBox(0, "无法执行", "不存在:" & $binary_file)
                        EndIf
        EndSwitch
WEnd

评分

参与人数 2金钱 +20 收起 理由
zmdzhxj + 10
梦倾天下 + 10 谢谢~!

查看全部评分

发表于 2016-9-26 19:07:15 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$type_ini= @ScriptDir & "\ini\install.ini"
$type_link=IniReadSection($type_ini,"type")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 458, 280, 192, 124)
$Button1 = GUICtrlCreateButton($type_link[1][1], 15, 32, 100, 33)
$button2 = GUICtrlCreateButton($type_link[2][1], 129, 32, 100, 33)
$Button3 = GUICtrlCreateButton($type_link[3][1], 15, 78, 100, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$binary_file = ""
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $binary_file = IniRead($type_ini, GUICtrlRead($Button1), "path", "")
                        Run($binary_file)
                        If @error Then
                                MsgBox(0, "无法执行", "不存在:" & $binary_file)
                        EndIf
                Case $Button2
                        $binary_file = IniRead($type_ini, GUICtrlRead($Button2), "path", "")
                        Run($binary_file)
                        If @error Then
                                MsgBox(0, "无法执行", "不存在:" & $binary_file)
                        EndIf
                Case $Button3
                        $binary_file = IniRead($type_ini, GUICtrlRead($Button3), "path", "")
                        Run($binary_file)
                        If @error Then
                                MsgBox(0, "无法执行", "不存在:" & $binary_file)
                        EndIf
        EndSwitch
WEnd
 楼主| 发表于 2016-9-27 15:14:55 | 显示全部楼层
回复 3# veket_linux


    谢谢!对哦,可以用读到的名称再去iniread,脑子没转过来,谢谢Veket大神
发表于 2016-10-19 14:47:14 | 显示全部楼层
学习下,数组不懂
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-19 11:04 , Processed in 0.083297 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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