水木子 发表于 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

由于我对系统程序的调用不熟悉,所以上面分代码用的模拟鼠标操作。(见笑啦!):face (37):

接下来再写一个读取多行和跳行的。

131738 发表于 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
        $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
;===读取多行,跳行同理

水木子 发表于 2009-11-24 20:30:04

LZ大概就是这意思吧?

jchang 发表于 2009-11-26 20:59:54

根据水木子的回复我已经写出了符合要求的脚本,非常感谢各位的回复!

auhj887 发表于 2010-4-11 21:25:19

牛。。。。。。。。。。。。好好学。。。。。。。。。。

renxiaoyao 发表于 2011-10-23 10:22:37

回复 16# 水木子

{:face (316):}感谢水木子,学到了!
页: 1 [2]
查看完整版本: 如何获取外部listview的每行内容