用QTP的描述性编程高亮显示任意对象

上一篇 / 下一篇  2013-06-15 11:05:00

这里运用描述性编程实现高亮显示计算器中的0到9的按钮对象。
把以下代码拷到QTP中,点“运行”,看看效果。
注:本程序以windows XP下的计算器演示,若使用windows 2000的计算器无效。


SystemUtil.Run "C:\WINDOWS\system32\calc.exe","","C:\WINDOWS\system32","open"
For i =0 to 9
HighlightAll Window("regexpwndclass:=SciCalc").WinButton("text:=" & cstr(i) )
Next


Sub HighlightAll(TestObject) 

       Dim Parent, Desc, Props, PropsCount, MaxIndex, i, Objs 
       If IsEmpty(TestObject.GetTOProperty("parent")) Then 
              Set Parent = Desktop 
       Else 
              Set Parent = TestObject.GetTOProperty("parent") 
       End If 
       Set Desc = Description.Create 
       Set Props = TestObject.GetTOProperties 
       PropsCount = Props.Count - 1 
       For i = 0 to PropsCount 
              Desc(Props(i).Name).Value = Props(i).Value 
       Next 
       Set bjs = Parent.ChildObjects(Desc) 
       MaxIndex= Objs.Count - 1 
       For i = 0 to MaxIndex 
              Objs.Item(i).Highlight 
       Next 

End Sub

TAG:

 

评分:0

我来说两句

日历

« 2024-05-12  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 52222
  • 日志数: 64
  • 建立时间: 2012-04-10
  • 更新时间: 2013-11-29

RSS订阅

Open Toolbar