返回列表 发帖

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

  1. #include <ButtonConstants.au3>
  2. #include <GUIConstantsEx.au3>
  3. #include <TabConstants.au3>
  4. #include <WindowsConstants.au3>
  5. #include <GuiTab.au3>
  6. #include <GuiListView.au3>
  7. #include <GuiImageList.au3>
  8. #include <WinAPISys.au3>
  9. #include <GuiEdit.au3>
  10. #include <array.au3>
  11. #include <WinAPIFiles.au3>




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

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

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

  43. Func sj()
  44. $z = 0
  45. $type=IniReadSection($cczzgjpzwj,"Type")

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

  48. For $j=1 To $subnumber[0][0]
  49.   $info=IniReadSection($cczzgjpzwj,$subnumber[$j][1])
  50.     GUICtrlCreateListViewItem($info[$j][1]),$liseview1)
  51.           $z +=1
  52.    Next
  53.    Next
  54. EndFunc



  55. While 1
  56.         $nMsg = GUIGetMsg()
  57.         Switch $nMsg
  58.                 Case $GUI_EVENT_CLOSE
  59.                         Exit
  60.                  Case $Button1
  61.                         sj()


  62.         EndSwitch
  63. WEnd
复制代码

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


下面的图不是己经读取了:
附件: 您需要登录才可以下载或查看附件。没有帐号?加入

TOP

  1. #include <ButtonConstants.au3>
  2. #include <GUIConstantsEx.au3>
  3. #include <TabConstants.au3>
  4. #include <WindowsConstants.au3>
  5. #include <GuiTab.au3>
  6. #include <GuiListView.au3>
  7. #include <GuiImageList.au3>
  8. #include <WinAPISys.au3>
  9. #include <GuiEdit.au3>
  10. #include <array.au3>
  11. #include <WinAPIFiles.au3>




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

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


  40. Func sj()
  41. GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
  42. $sjrj=IniReadSection($cczzgjpzwj,"设计软件")
  43. $lisetviewitem1=GUICtrlCreateListViewItem($sjrj[1][0]&"|"&$sjrj[1][1],$listview1)
  44. $lisetviewitem2=GUICtrlCreateListViewItem($sjrj[2][0]&"|"&$sjrj[2][1],$listview1)
  45. EndFunc



  46. While 1
  47.         $nMsg = GUIGetMsg()
  48.         Switch $nMsg
  49.                 Case $GUI_EVENT_CLOSE
  50.                         Exit
  51.                  Case $Button1
  52.                         sj()
  53.      EndSwitch
  54. WEnd
复制代码
附件: 您需要登录才可以下载或查看附件。没有帐号?加入

TOP

回复 2# chzj589


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

TOP

回复  chzj589


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

  1. #include <GUIConstantsEx.au3>

  2. #include <TabConstants.au3>

  3. #include <WindowsConstants.au3>

  4. #include <GuiTab.au3>

  5. #include <GuiListView.au3>

  6. #include <GuiImageList.au3>

  7. Global $cczzgjpzwj=@ScriptDir &"\isa.ini"

  8. IniWrite($cczzgjpzwj,"设计软件","CAD","2010")

  9. IniWrite($cczzgjpzwj,"设计软件","creo","3.0")

  10. #Region ### START Koda GUI section ### Form=

  11. $Form1 = GUICreate("Form1", 615, 438, 192, 124)

  12. $Tab1 = GUICtrlCreateTab(8, 8, 593, 417)

  13. $TabSheet1 = GUICtrlCreateTabItem("基础功能")

  14. $TabSheet2 = GUICtrlCreateTabItem("软件安装")

  15. GUICtrlSetState($TabSheet2, $GUI_SHOW)

  16. $Group1 = GUICtrlCreateGroup("", 24, 56, 75, 337)

  17. $Button1 = GUICtrlCreateButton("设计软件", 24, 56, 75, 25)

  18. $Button3 = GUICtrlCreateButton("办公软件", 24, 80, 75, 25)

  19. $Button4 = GUICtrlCreateButton("浏览器设置", 24, 104, 75, 25)

  20. $Button5 = GUICtrlCreateButton("文印打印机", 24, 128, 75, 25)

  21. $Button6 = GUICtrlCreateButton("邮箱配置", 24, 152, 75, 25)

  22. $Button7 = GUICtrlCreateButton("系统优化", 24, 176, 75, 25)

  23. $Button8 = GUICtrlCreateButton("其他", 24, 200, 75, 25)

  24. ControlClick("Form1", "", "[CLASS:Button; TEXT:设计软件; INSTANCE:1]");运行控件

  25. GUICtrlCreateGroup("", -99, -99, 1, 1)

  26. ;$Group2 = GUICtrlCreateGroup("", 112, 56, 441, 337)

  27. $ListView1 = GUICtrlCreateListView("", 112, 56, 441, 337, $LVS_REPORT, $WS_EX_CLIENTEDGE)

  28. GUICtrlSetBkColor(-1, $CLR_MONEYGREEN);0xC0C0C0); 背景色 0xCCCCAC);

  29. _GUICtrlListView_SetBkColor($ListView1, 14675183);$CLR_MONEYGREEN);

  30. _GUICtrlListView_AddColumn($ListView1, "序号", 60)

  31. _GUICtrlListView_AddColumn($ListView1, "软件", 100)

  32. _GUICtrlListView_AddColumn($ListView1, "安装软件", 100)

  33. _GUICtrlListView_AddColumn($ListView1, "备注", 200)

  34. Local $hImage = _GUIImageList_Create(16, 16, 5, 3)

  35. _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)

  36. $hImagea = _GUIImageList_Create(1, 18);30为每行的间距(即网格高度)

  37. _GUICtrlListView_SetImageList($ListView1, $hImagea, 1)

  38. _GUICtrlListView_SetImageList($ListView1, $hImage, 1)

  39. _GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_INFOTIP))

  40. ;_Read()

  41. ;GUICtrlCreateGroup("", -99, -99, 1, 1)

  42. $TabSheet3 = GUICtrlCreateTabItem("软件卸载")



  43. ControlClick("Form1", "", "[CLASS:Button; TEXT:设计软件; INSTANCE:1]");运行控件

  44. #EndRegion ### END Koda GUI section ###


  45.         $nMsg = GUIGetMsg()

  46.         Switch $nMsg

  47.                 Case $GUI_EVENT_CLOSE

  48.                         Exit

  49.                 Case $Button1

  50.                         _Read()

  51.         EndSwitch


  52. Func _Read()

  53.         GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)

  54.         Local $IniFile = @ScriptDir & "\isa.ini"

  55.  

  56.         Local $aIni = IniReadSectionNames($IniFile)

  57.         If @error Then Exit MsgBox(4096, "", "错误, 读取INI文件失败.")

  58.         Local $ii, $jj, $var

  59.         Local $i = 0

  60.         For $jj = 1 To $aIni[0]

  61.                 $var = IniReadSection($IniFile, $aIni[$jj])

  62.                 For $ii = 1 To $var[0][0]

  63.                         ;MsgBox(4096, "", "字段名: " & $aIni[$jj] & @CRLF & "关键字: " & $var[$ii][0] & @CRLF & "值: " & $var[$ii][1])

  64.                         _GUICtrlListView_AddItem($ListView1, $ii, 0)

  65.                         _GUICtrlListView_AddSubItem($ListView1, $i, $aIni[$jj], 1)

  66.                         _GUICtrlListView_AddSubItem($ListView1, $i, $var[$ii][0], 2)

  67.                         _GUICtrlListView_AddSubItem($ListView1, $i, $var[$ii][1], 3)

  68.                         $i += 1

  69.                 Next

  70.         Next

  71. EndFunc   ;==>_Read

复制代码 高亮切换

TOP

回复 5# chzj589


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

TOP

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

TOP

回复 7# chzj589


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

TOP

回复 8# jcaixuexi
那还是打开40行的;_Read()
_Read()
把ControlClick("Form1", "", "[CLASS:Button; TEXT:设计软件; INSTANCE:1]")
这一行注释掉

TOP

回复 9# chzj589


    可以啦,谢谢哈,大神,还有个问题,怎样在listview里面添加复选框。
附件: 您需要登录才可以下载或查看附件。没有帐号?加入

TOP

回复 10# jcaixuexi
  1. $ListView1=GUICtrlCreateListView("", 112, 56, 465, 337)

  2. ;ListView复选框

  3. _GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT))

复制代码 高亮切换

TOP

返回列表