|
那位高手 有时间 帮帮忙啊 !!!最近看看了QTP 写了个脚本 但是出现了和奇怪的错位!!!哪位高手帮忙解决下 !!!
如果只执行一次(最外面的循环)没有错, 但是循环就报错了,,弄了好久没明白!!!求解 说明:代码中的Parameter("chkname")为QTPro.exe,parameter("rltpath")为一个自己设的路径 E:\result.xls
整个代码如下:
For circ = 0 to 1
systemutil.Run "C:\WINDOWS\system32\taskmgr.exe","","C:\WINDOWS\system32","open"
If dialog("Windows 任务管理器").Exist Then
Dim i ,cntc ,chknam ,roname ,mytime , mydate ,cntl
mytime = time
mydate = date
chknam = Parameter("chkname")
cntl = dialog("Windows 任务管理器").WinListView("SysListView32").GetROProperty("items count")
cntc = dialog("Windows 任务管理器").WinListView("SysListView32").ColumnCount
With dialog("Windows 任务管理器").WinListView("SysListView32")
For i = 0 To cntl - 1
dialog("Windows 任务管理器").WinListView("SysListView32").Select i
roname = dialog("Windows 任务管理器").WinListView("SysListView32").GetSelection
If chknam = roname Then
Dim fso ,f
Dim resultnames ,resultvelues ,iname() ,ivelue()
Set fso = CreateObject("scripting.filesystemobject")
Set f = fso.OpenTextFile(parameter("rltpath"),8,true,-2)
ReDim iname(cntc) ,ivelue(cntc)
f.Write vbcrlf & mydate & vbtab
f.Write mytime & vbcrlf
For j = 0 to cntc - 2
iname(j) = .GetColumnHeader(j)
f.Write iname(j)&vbtab
next
iname(cntc-1) = .GetColumnHeader(cntc-1)
f.Write iname(j) & vbcrlf
For j =0 to cntc-1
iname = .GetColumnHeader(j)
ivelue(j) = .GetSubItem(i,iname(j))
f.Write ivelue(j) & vbtab
Next
For j = 0 to cntc -1
If iname(j) = "内存使用" or iname(j) = "内存使用" or iname(j) ="高峰内存使用" or iname(j) ="虚拟内存大小" or iname(j) ="页面缓冲池" or iname(j) ="非页面缓冲池" or iname(j) ="内存增量" Then
ivelue(j) = left (cstr ( ivelue(j)), len( ivelue(j))-1)
resultNames =resultNames +iname(j) +" (k) *"
resultVelues =resultVelues+ ivelue(j)+ "*"
elseif iname(j) = "页面错误" or iname(j) ="页面错误增量"or iname(j) ="句柄数" or iname(j) ="线程数" or iname(j) ="USER 对象" or iname(j) ="GDI 对象" or iname(j) = "I/O 读取" or iname(j) ="I/O 写入"or iname(j) ="I/O 其它" or iname(j) ="I/O 读取字节"or iname(j) = "I/O 字节" or iname(j) = "I/O 写入字节" or iname(j) ="”I/O 其他字节" then
resultNames =resultNames +iname(j) +"*"
resultVelues =resultVelues+ ivelue(j)+ "*"
Parameter("resultNames") = resultNames
Parameter("resultVelues") = resultVelues
End If
Next
Exit for
End If
next
End With
Set fso = nothing
Set f = nothing
If chkname <> roname Then
reporter.ReportEvent micWarning, "warming","应用程序不存在"
End If
dialog("Windows 任务管理器").Close
End If
wait (2)
Next
提示信息见附件
[ 本帖最后由 mhgzs 于 2010-8-26 13:44 编辑 ] |
|