东拼西凑了一个脚本,将INI的字段名读取到下拉列表(Combo)中,并在下面的列表中(ListView)中显示此字段名下的所有关键字以及值。目前只能实现在Combo中选中某一个字段名,然后点击按钮“切换到此组”才能在ListView显示当前字段名下的内容。
求助内容:
1、有没有办法在Combo中选中了以后就直接在ListView中显示而不需要点按钮
2、因为是拼凑出来的,还能不能再优化了
3、如果不想在下拉列表中显示某字段名(位置不定)该如何操作,现在只能做到将第一个字段名跳过不显示
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <IE.au3>
#include <_ini.au3>
$title = "medoclub.taobao.com"
Opt("GUIOnEventMode", 1)
$dir = @ScriptDir & "\Setting.ini"
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate($title, 100, 800, 0, 0)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$zidong1 = GUICtrlCreateButton(" 切换到此组 ", 5, 30)
GUICtrlSetOnEvent($zidong1, "_liebiao")
$ListView1 = GUICtrlCreateListView("双击换号 ||", 5, 90, 90, 695)
$var = IniReadSectionNames("Setting.ini")
If @error Then
MsgBox(4096, "读取配置错误", "请确认程序目录下有Setting.ini." & @CR & "且此INI内容不为空", 5)
Exit
Else
$Combo1 = GUICtrlCreateCombo($var[1], 5, 5, 90, 25)
For $i = 2 To $var[0]
$a = GUICtrlSetData($Combo1, $var[$i])
Next
EndIf
GUISetState(@SW_SHOW)
$rdini = _IniReadSection($dir, GUICtrlRead($Combo1))
$z = 0
For $i = 1 To $rdini[0][0]
GUICtrlCreateListViewItem($rdini[$i][0], $ListView1)
_GUICtrlListView_AddSubItem($ListView1, $z, $rdini[$i][1], 1, $z + 1)
$z += 1
Next
GUICtrlSetData($ListView1, GUICtrlRead($Combo1))
While 1
Sleep(100)
WEnd
Func Form1Close()
Exit 0
EndFunc ;==>Form1Close
Func _liebiao()
GUICtrlDelete($ListView1)
$ListView1 = GUICtrlCreateListView("双击换号 ||", 5, 90, 90, 605)
$rdini = _IniReadSection($dir, GUICtrlRead($Combo1))
$z = 0
For $i = 1 To $rdini[0][0]
GUICtrlCreateListViewItem($rdini[$i][0], $ListView1)
_GUICtrlListView_AddSubItem($ListView1, $z, $rdini[$i][1], 1, $z + 1)
$z += 1
Next
GUICtrlSetData($ListView1, GUICtrlRead($Combo1))
EndFunc ;==>_liebiao
setting.ini的内容[组1]
组1小号1=medoclub.taobao.com
组1小号2=medoclub.taobao.com
[组2]
组2小号1=medoclub.taobao.com
组2小号2=medoclub.taobao.com
[组3]
组2小号1=medoclub.taobao.com
组2小号2=medoclub.taobao.com
] |