jcaixuexi 发表于 2017-1-11 12:57:29

关于无法把ini文件数据导入到listview里面去

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WinAPISys.au3>
#include <GuiEdit.au3>
#include <array.au3>
#include <WinAPIFiles.au3>




#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Tab1 = GUICtrlCreateTab(8, 8, 593, 417)
$TabSheet1 = GUICtrlCreateTabItem("基础功能")
$TabSheet2 = GUICtrlCreateTabItem("软件安装")
GUICtrlSetState(-1,$GUI_SHOW)
$Group1 = GUICtrlCreateGroup("", 24, 56, 75, 337)
$Button1 = GUICtrlCreateButton("设计软件", 24, 56, 75, 25)
$Button3 = GUICtrlCreateButton("办公软件", 24, 80, 75, 25)
$Button4 = GUICtrlCreateButton("浏览器设置", 24, 104, 75, 25)
$Button5 = GUICtrlCreateButton("文印打印机", 24, 128, 75, 25)
$Button6 = GUICtrlCreateButton("邮箱配置", 24, 152, 75, 25)
$Button7 = GUICtrlCreateButton("系统优化", 24, 176, 75, 25)
$Button8 = GUICtrlCreateButton("其他", 24, 200, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 112, 56, 441, 337)
$ListView1=GUICtrlCreateListView("", 112, 56, 441, 337)
_GUICtrlListView_AddColumn($ListView1, "软件名",100)
_GUICtrlListView_AddColumn($ListView1, "软件架构",60)
_GUICtrlListView_AddColumn($ListView1, "备注",200)

GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet3 = GUICtrlCreateTabItem("软件卸载")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $cczzgjpzwj="D:\Mydata\ex_jiangchao\Desktop\cc自助工具1.1\is.ini"
IniWrite($cczzgjpzwj,"Type","1","设计软件")
IniWrite($cczzgjpzwj,"Type","2","办公软件")
IniWrite($cczzgjpzwj,"设计软件.list","1","cad")
IniWrite($cczzgjpzwj,"设计软件.list","2","CREO")
IniWrite($cczzgjpzwj,"办公软件.list","1","office2010")

Func sj()
$z = 0
$type=IniReadSection($cczzgjpzwj,"Type")

For $i=1 To $type
        $subNumber=IniReadSection($cczzgjpzwj,$type[$i]&".list");

For $j=1 To $subnumber
$info=IniReadSection($cczzgjpzwj,$subnumber[$j])
    GUICtrlCreateListViewItem($info[$j]),$liseview1)
          $z +=1
   Next
   Next
EndFunc



While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
               Case $Button1
                        sj()


        EndSwitch
WEnd

chzj589 发表于 2017-1-11 13:40:32


jcaixuexi 发表于 2017-1-11 12:57 http://www.autoitx.com/images/common/back.gif

下面的图不是己经读取了:

jcaixuexi 发表于 2017-1-11 14:03:05

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WinAPISys.au3>
#include <GuiEdit.au3>
#include <array.au3>
#include <WinAPIFiles.au3>




#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Tab1 = GUICtrlCreateTab(8, 8, 593, 417)
$TabSheet1 = GUICtrlCreateTabItem("基础功能")
$TabSheet2 = GUICtrlCreateTabItem("软件安装")
GUICtrlSetState(-1,$GUI_SHOW)
$Group1 = GUICtrlCreateGroup("", 24, 56, 75, 337)
$Button1 = GUICtrlCreateButton("设计软件", 24, 56, 75, 25)
$Button3 = GUICtrlCreateButton("办公软件", 24, 80, 75, 25)
$Button4 = GUICtrlCreateButton("浏览器设置", 24, 104, 75, 25)
$Button5 = GUICtrlCreateButton("文印打印机", 24, 128, 75, 25)
$Button6 = GUICtrlCreateButton("邮箱配置", 24, 152, 75, 25)
$Button7 = GUICtrlCreateButton("系统优化", 24, 176, 75, 25)
$Button8 = GUICtrlCreateButton("其他", 24, 200, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 112, 56, 441, 337)
$ListView1=GUICtrlCreateListView("", 112, 56, 441, 337)
_GUICtrlListView_AddColumn($ListView1, "软件名",100)
_GUICtrlListView_AddColumn($ListView1, "软件架构",60)
_GUICtrlListView_AddColumn($ListView1, "备注",200)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet3 = GUICtrlCreateTabItem("软件卸载")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $cczzgjpzwj="D:\Mydata\ex_jiangchao\Desktop\cc自助工具1.1\is.ini"
IniWrite($cczzgjpzwj,"设计软件","CAD","2010")
IniWrite($cczzgjpzwj,"设计软件","creo","3.0")


Func sj()
GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
$sjrj=IniReadSection($cczzgjpzwj,"设计软件")
$lisetviewitem1=GUICtrlCreateListViewItem($sjrj&"|"&$sjrj,$listview1)
$lisetviewitem2=GUICtrlCreateListViewItem($sjrj&"|"&$sjrj,$listview1)
EndFunc



While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
               Case $Button1
                        sj()
   EndSwitch
WEnd

jcaixuexi 发表于 2017-1-11 14:04:03

回复 2# chzj589


    我只通过下面的写入一部分的调取,要是数据很多的,就很麻烦

chzj589 发表于 2017-1-11 14:32:18

回复chzj589


    我只通过下面的写入一部分的调取,要是数据很多的,就很麻烦
jcaixuexi 发表于 2017-1-11 14:04 http://www.autoitx.com/images/common/back.gif

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
Global $cczzgjpzwj=@ScriptDir &"\isa.ini"
IniWrite($cczzgjpzwj,"设计软件","CAD","2010")
IniWrite($cczzgjpzwj,"设计软件","creo","3.0")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Tab1 = GUICtrlCreateTab(8, 8, 593, 417)
$TabSheet1 = GUICtrlCreateTabItem("基础功能")
$TabSheet2 = GUICtrlCreateTabItem("软件安装")
GUICtrlSetState($TabSheet2, $GUI_SHOW)
$Group1 = GUICtrlCreateGroup("", 24, 56, 75, 337)
$Button1 = GUICtrlCreateButton("设计软件", 24, 56, 75, 25)
$Button3 = GUICtrlCreateButton("办公软件", 24, 80, 75, 25)
$Button4 = GUICtrlCreateButton("浏览器设置", 24, 104, 75, 25)
$Button5 = GUICtrlCreateButton("文印打印机", 24, 128, 75, 25)
$Button6 = GUICtrlCreateButton("邮箱配置", 24, 152, 75, 25)
$Button7 = GUICtrlCreateButton("系统优化", 24, 176, 75, 25)
$Button8 = GUICtrlCreateButton("其他", 24, 200, 75, 25)
ControlClick("Form1", "", "");运行控件
GUICtrlCreateGroup("", -99, -99, 1, 1)
;$Group2 = GUICtrlCreateGroup("", 112, 56, 441, 337)
$ListView1 = GUICtrlCreateListView("", 112, 56, 441, 337, $LVS_REPORT, $WS_EX_CLIENTEDGE)
GUICtrlSetBkColor(-1, $CLR_MONEYGREEN);0xC0C0C0); 背景色 0xCCCCAC);
_GUICtrlListView_SetBkColor($ListView1, 14675183);$CLR_MONEYGREEN);
_GUICtrlListView_AddColumn($ListView1, "序号", 60)
_GUICtrlListView_AddColumn($ListView1, "软件", 100)
_GUICtrlListView_AddColumn($ListView1, "安装软件", 100)
_GUICtrlListView_AddColumn($ListView1, "备注", 200)
Local $hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
$hImagea = _GUIImageList_Create(1, 18);30为每行的间距(即网格高度)
_GUICtrlListView_SetImageList($ListView1, $hImagea, 1)
_GUICtrlListView_SetImageList($ListView1, $hImage, 1)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_INFOTIP))
;_Read()
;GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet3 = GUICtrlCreateTabItem("软件卸载")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW,$Form1)
ControlClick("Form1", "", "");运行控件
#EndRegion ### END Koda GUI section ###
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        _Read()
        EndSwitch
WEnd
Func _Read()
        GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
        Local $IniFile = @ScriptDir & "\isa.ini"

        Local $aIni = IniReadSectionNames($IniFile)
        If @error Then Exit MsgBox(4096, "", "错误, 读取INI文件失败.")
        Local $ii, $jj, $var
        Local $i = 0
        For $jj = 1 To $aIni
                $var = IniReadSection($IniFile, $aIni[$jj])
                For $ii = 1 To $var
                        ;MsgBox(4096, "", "字段名: " & $aIni[$jj] & @CRLF & "关键字: " & $var[$ii] & @CRLF & "值: " & $var[$ii])
                        _GUICtrlListView_AddItem($ListView1, $ii, 0)
                        _GUICtrlListView_AddSubItem($ListView1, $i, $aIni[$jj], 1)
                        _GUICtrlListView_AddSubItem($ListView1, $i, $var[$ii], 2)
                        _GUICtrlListView_AddSubItem($ListView1, $i, $var[$ii], 3)
                        $i += 1
                Next
        Next
EndFunc   ;==>_Read

jcaixuexi 发表于 2017-1-11 15:22:59

回复 5# chzj589


谢谢哈,确实可以实现之前的想法,大神,还问一点,如果我想默认打开这个exe文件的时候,打开的是基础功能那个tab,只是点击到软件安装的时候,他默认点击到设计软件那里。还有一个listview里面怎样添加按钮的。

chzj589 发表于 2017-1-11 16:59:02

回复 6# jcaixuexi
你在SciTe编辑器里调试代码
GUICtrlSetState($TabSheet2, $GUI_SHOW)是显示
$TabSheet2 = GUICtrlCreateTabItem("软件安装")
去掉GUICtrlSetState($TabSheet2, $GUI_SHOW)就显示
$TabSheet1 = GUICtrlCreateTabItem("基础功能")
多调整几次,就能知道。
ControlClick("Form1", "", "");运行控件
他默认点击到设计软件。
还有一个listview里面怎样添加按钮的????

jcaixuexi 发表于 2017-1-12 14:37:18

回复 7# chzj589


    如果默认打开的显示的是基础功能,点击软件安装,自动点击到设计软件那里,ControlClick("Form1", "", "")这行应该加在哪里的

chzj589 发表于 2017-1-12 16:05:03

回复 8# jcaixuexi
那还是打开40行的;_Read()
_Read()
把ControlClick("Form1", "", "")
这一行注释掉

jcaixuexi 发表于 2017-1-12 16:43:24

回复 9# chzj589


    可以啦,谢谢哈,大神,还有个问题,怎样在listview里面添加复选框。

chzj589 发表于 2017-1-12 17:01:36

回复 10# jcaixuexi

$ListView1=GUICtrlCreateListView("", 112, 56, 465, 337)
;ListView复选框
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT))
页: [1]
查看完整版本: 关于无法把ini文件数据导入到listview里面去