找回密码
 加入
搜索
楼主: jchang

如何获取外部listview的每行内容

 火.. [复制链接]
发表于 2009-11-24 20:10:31 | 显示全部楼层
本帖最后由 水木子 于 2009-11-24 20:52 编辑

我们以查看系统服务项目为例:(回答LZ的第1个问题)
$t = "系统配置实用程序"

Run('msconfig.exe')
WinWaitActive ($t)
ControlCommand ( $t, "", 'SysTabControl321' , "TabRight")
ControlCommand ( $t, "", 'SysTabControl321' , "TabRight")
ControlCommand ( $t, "", 'SysTabControl321' , "TabRight")
ControlCommand ( $t, "", 'SysTabControl321' , "TabRight")
Sleep(500)

ControlListView ( $t, "", 'SysListView321', "SelectClear")
ControlListView ( $t, "", 'SysListView321', "Select",3)
Sleep(500)

;===>第1问:读取某行
$i = ControlListView ( $t, "", 'SysListView321', "GetSelected")
$b1 = ControlListView ( $t, "", 'SysListView321', "GetText", $i ,0)
$b2 = ControlListView ( $t, "", 'SysListView321', "GetText", $i ,1)
$b3 = ControlListView ( $t, "", 'SysListView321', "GetText", $i ,2)
$b4 = ControlListView ( $t, "", 'SysListView321', "GetText", $i ,3)
MsgBox(0,'', '当前读取第'&$i+1&'行信息:'&@LF& '服务:'&$b1&@LF&'基本的:'&$b2&@LF&'制造商:'&$b3&@LF&'状态:'&$b4)
;===第1问:读取某行 
发表于 2009-11-24 20:13:55 | 显示全部楼层
由于我对系统程序的调用不熟悉,所以上面分代码用的模拟鼠标操作。(见笑啦!)

接下来再写一个读取多行和跳行的。
发表于 2009-11-24 20:26:44 | 显示全部楼层
看来 run 还是不能少的!
发表于 2009-11-24 20:29:16 | 显示全部楼层
本帖最后由 水木子 于 2009-11-24 20:52 编辑

有了单行读取的例子,多行和跳行就更简单了,稍微改了下。
$t = "系统配置实用程序"

Run('msconfig.exe')
WinWaitActive ($t)
ControlCommand ( $t, "", 'SysTabControl321' , "TabRight")
ControlCommand ( $t, "", 'SysTabControl321' , "TabRight")
ControlCommand ( $t, "", 'SysTabControl321' , "TabRight")
ControlCommand ( $t, "", 'SysTabControl321' , "TabRight")
Sleep(500)

ControlListView ( $t, "", 'SysListView321', "SelectClear")
ControlListView ( $t, "", 'SysListView321', "Select",3)
Sleep(500)

;===>第1问:读取某行
$i = ControlListView ( $t, "", 'SysListView321', "GetSelected")
$b1 = ControlListView ( $t, "", 'SysListView321', "GetText", $i ,0)
$b2 = ControlListView ( $t, "", 'SysListView321', "GetText", $i ,1)
$b3 = ControlListView ( $t, "", 'SysListView321', "GetText", $i ,2)
$b4 = ControlListView ( $t, "", 'SysListView321', "GetText", $i ,3)
MsgBox(0,'', '当前读取第'&$i+1&'行信息:'&@LF& '服务:'&$b1&@LF&'基本的:'&$b2&@LF&'制造商:'&$b3&@LF&'状态:'&$b4)
;===第1问:读取某行

;===>读取多行,跳行同理
ControlListView ( $t, "", 'SysListView321', "SelectClear")
ControlListView ( $t, "", 'SysListView321', "Select",2,5)
Sleep(1000)

$a = ControlListView ( $t, "", 'SysListView321', "GetSelected" ,1)
$a1 = StringSplit ( $a, "|" )
For $i = 1 To $a1[0]
        $a = ControlListView ( $t, "", 'SysListView321', "GetSelected")
        $b1 = ControlListView ( $t, "", 'SysListView321', "GetText", $i ,0)
        $b2 = ControlListView ( $t, "", 'SysListView321', "GetText", $i ,1)
        $b3 = ControlListView ( $t, "", 'SysListView321', "GetText", $i ,2)
        $b4 = ControlListView ( $t, "", 'SysListView321', "GetText", $i ,3)
        MsgBox(0,'', '当前读取第'&$i+1&'行信息:'&@LF& '服务:'&$b1&@LF&'基本的:'&$b2&@LF&'制造商:'&$b3&@LF&'状态:'&$b4)
Next
;===读取多行,跳行同理

评分

参与人数 1金钱 +20 贡献 +10 收起 理由
afan + 20 + 10

查看全部评分

发表于 2009-11-24 20:30:04 | 显示全部楼层
LZ大概就是这意思吧?
 楼主| 发表于 2009-11-26 20:59:54 | 显示全部楼层
根据水木子的回复我已经写出了符合要求的脚本,非常感谢各位的回复!
发表于 2010-4-11 21:25:19 | 显示全部楼层
牛。。。。。。。。。。。。好好学。。。。。。。。。。
发表于 2011-10-23 10:22:37 | 显示全部楼层
回复 16# 水木子

感谢水木子,学到了!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-23 15:59 , Processed in 0.099574 second(s), 15 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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