找回密码
 加入
搜索
查看: 3743|回复: 7

[GUI管理] GUICtrlRead 如何取list的所有数值

  [复制链接]
发表于 2012-2-12 19:36:20 | 显示全部楼层 |阅读模式
$List1 = GUICtrlCreateList("", 14, 236, 475, 134)
        $i = 1
while 1
$key = regenumkey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $i)
if @error then exitloop
$softname=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"&$key,"DisplayName")
If @error<>-1 Then
If StringLeft($softname, 5) = "Adobe"  Or StringLeft($softname, 7) = "Windows" Then
GUICtrlSetData(-1,$softname)
EndIf
EndIf
$i = $i +1
wend
我有一个Save的botton,想把list的结果保存到txt.
所以用下面的代码,结果悲剧了,只保存了光标当前选中的一条记录,其他的记录都没有保存。
求解!
FileWrite(@DesktopDir &"\Report.txt,GUICtrlRead($List1))
发表于 2012-2-12 19:42:02 | 显示全部楼层
List 数据是你自己设置的,为何要重新读呢? 设置时同时储存到一个变量不就行了
发表于 2012-2-13 11:36:20 | 显示全部楼层
Afan 正解...
发表于 2012-2-13 13:24:15 | 显示全部楼层
回复 1# schoolwenxue


    先用_GUICtrlListView_GetItemCount获取项目总数。

然后使用for循环从1到总数遍历guictrlread(guictrlread(listview控件ID))读取每一行数据用stringsplit将读取到的数据用“|”隔开,使用filewriteline写入到记事本文件中。
 楼主| 发表于 2012-2-13 17:02:08 | 显示全部楼层
明白了,我再试试
 楼主| 发表于 2012-2-18 12:29:29 | 显示全部楼层
Func _save()
        FileWriteLine(@DesktopDir & "\Temp.csv","SoftwareName")
        $count = _GUICtrlListBox_GetCount($List1)
        For $i = 0 To $count Step +1
                $text = _GUICtrlListBox_GetText($List1,$i)
                FileWriteLine(@DesktopDir & "\Temp.csv",$text)
        Next
        MsgBox(64,"Tips","文件已保存到桌面上。")
        Exit
EndFunc
发表于 2012-2-18 16:19:16 | 显示全部楼层
XIANGAfan 学习。。。
发表于 2012-2-18 16:19:22 | 显示全部楼层
XIANGAfan 学习。。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-9 08:01 , Processed in 0.080067 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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