找回密码
 加入
搜索
查看: 3164|回复: 10

[AU3基础] 关于无法把ini文件数据导入到listview里面去

  [复制链接]
发表于 2017-1-11 12:57:29 | 显示全部楼层 |阅读模式
#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[0][0]
        $subNumber=IniReadSection($cczzgjpzwj,$type[$i][1]&".list");

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



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


        EndSwitch
WEnd
发表于 2017-1-11 13:40:32 | 显示全部楼层
jcaixuexi 发表于 2017-1-11 12:57


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

本帖子中包含更多资源

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

×
 楼主| 发表于 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[1][0]&"|"&$sjrj[1][1],$listview1)
$lisetviewitem2=GUICtrlCreateListViewItem($sjrj[2][0]&"|"&$sjrj[2][1],$listview1)
EndFunc



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

本帖子中包含更多资源

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

×
 楼主| 发表于 2017-1-11 14:04:03 | 显示全部楼层
回复 2# chzj589


    我只通过下面的写入一部分的调取,要是数据很多的,就很麻烦
发表于 2017-1-11 14:32:18 | 显示全部楼层
回复  chzj589


    我只通过下面的写入一部分的调取,要是数据很多的,就很麻烦
jcaixuexi 发表于 2017-1-11 14:04


#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", "", "[CLASS:Button; TEXT:设计软件; INSTANCE:1]");运行控件
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", "", "[CLASS:Button; TEXT:设计软件; INSTANCE:1]");运行控件
#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[0]
                $var = IniReadSection($IniFile, $aIni[$jj])
                For $ii = 1 To $var[0][0]
                        ;MsgBox(4096, "", "字段名: " & $aIni[$jj] & @CRLF & "关键字: " & $var[$ii][0] & @CRLF & "值: " & $var[$ii][1])
                        _GUICtrlListView_AddItem($ListView1, $ii, 0)
                        _GUICtrlListView_AddSubItem($ListView1, $i, $aIni[$jj], 1)
                        _GUICtrlListView_AddSubItem($ListView1, $i, $var[$ii][0], 2)
                        _GUICtrlListView_AddSubItem($ListView1, $i, $var[$ii][1], 3)
                        $i += 1
                Next
        Next
EndFunc   ;==>_Read
 楼主| 发表于 2017-1-11 15:22:59 | 显示全部楼层
回复 5# chzj589


谢谢哈,确实可以实现之前的想法,大神,还问一点,如果我想默认打开这个exe文件的时候,打开的是基础功能那个tab,只是点击到软件安装的时候,他默认点击到设计软件那里。还有一个listview里面怎样添加按钮的。
发表于 2017-1-11 16:59:02 | 显示全部楼层
回复 6# jcaixuexi
你在SciTe编辑器里调试代码
GUICtrlSetState($TabSheet2, $GUI_SHOW)是显示
$TabSheet2 = GUICtrlCreateTabItem("软件安装")
去掉GUICtrlSetState($TabSheet2, $GUI_SHOW)就显示
$TabSheet1 = GUICtrlCreateTabItem("基础功能")
多调整几次,就能知道。
ControlClick("Form1", "", "[CLASS:Button; TEXT:设计软件; INSTANCE:1]");运行控件
他默认点击到设计软件。
还有一个listview里面怎样添加按钮的????
 楼主| 发表于 2017-1-12 14:37:18 | 显示全部楼层
回复 7# chzj589


    如果默认打开的显示的是基础功能,点击软件安装,自动点击到设计软件那里,ControlClick("Form1", "", "[CLASS:Button; TEXT:设计软件; INSTANCE:1]")这行应该加在哪里的
发表于 2017-1-12 16:05:03 | 显示全部楼层
回复 8# jcaixuexi
那还是打开40行的;_Read()
_Read()
把ControlClick("Form1", "", "[CLASS:Button; TEXT:设计软件; INSTANCE:1]")
这一行注释掉
 楼主| 发表于 2017-1-12 16:43:24 | 显示全部楼层
回复 9# chzj589


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

本帖子中包含更多资源

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

×
发表于 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))
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-22 10:58 , Processed in 0.094192 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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