[已解决]二维数组怎么调用ini配置文件
本帖最后由 梦倾天下 于 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, 15, 32, 100, 33)
$button2 = GUICtrlCreateButton($type_link, 129, 32, 100, 33)
$Button3 = GUICtrlCreateButton($type_link, 15, 78, 100, 33)
Case $Button1
run("获取到path的值")
Case $Button2
Case $Button3-------------------------------
install.ini文件内容为:
1=酷我音乐
2=QQ影音
3=腾讯QT
[酷我音乐]
name=酷我音乐
path=D:\software\酷我音乐.exe
name=QQ影音
path=D:\software\QQ影音.exe
[腾讯QT]
name=腾讯QT
path=D:\software\腾讯QT.exe
---------------------------
按钮数量不变,就名称和软件安装路径会变,所以希望通过直接修改ini来更改 #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, 15, 32, 100, 33)
$button2 = GUICtrlCreateButton($type_link, 129, 32, 100, 33)
$Button3 = GUICtrlCreateButton($type_link, 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 #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, 15, 32, 100, 33)
$button2 = GUICtrlCreateButton($type_link, 129, 32, 100, 33)
$Button3 = GUICtrlCreateButton($type_link, 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 回复 3# veket_linux
谢谢!对哦,可以用读到的名称再去iniread,脑子没转过来,谢谢Veket大神 学习下,数组不懂
页:
[1]