调用Windows的API,在QTP中实现高亮对象的方法
2010-08-25 11:29
567 查看
在QTP的帮助文档中,展示了如何调用Windows自身的API来实现更灵活的操作。
以下的方法实现在屏幕上高亮一个矩形区域,来突出被测对象的位置。
QTP本身也封装了对象的Highlight方法,可以通过object.Highlight 来调用。
以下的方法实现在屏幕上高亮一个矩形区域,来突出被测对象的位置。
' Declare necessary APIs Extern.Declare micHwnd, "GetDesktopWindow", "User32.DLL", "GetDesktopWindow" Extern.Declare micULong, "GetWindowDC", "User32.DLL", "GetWindowDC", micHwnd Extern.Declare micInteger, "ReleaseDC", "User32.DLL", "ReleaseDC", micHwnd, micULong Extern.Declare micULong, "CreatePen", "Gdi32.DLL", "CreatePen", micInteger, micInteger, micDword Extern.Declare micInteger, "SetROP2", "Gdi32.DLL", "SetROP2", micULong, micInteger Extern.Declare micULong, "SelectObject", "Gdi32.DLL", "SelectObject", micULong, micULong Extern.Declare micULong, "DeleteObject", "Gdi32.DLL", "DeleteObject", micULong Extern.Declare micULong, "GetStockObject", "Gdi32.DLL", "GetStockObject", micInteger Extern.Declare micULong, "Rectangle", "Gdi32.DLL", "Rectangle", micULong, micInteger, micInteger, micInteger, micInteger Function HighlightRect (X, Y, W, H, Times) ' Get the Desktop DC hDC = Extern.GetWindowDC (Extern.GetDesktopWindow) ' Create a three pixel wide pen hPen = Extern.CreatePen (6, 3, RGB(0, 0, 0)) ' PS_INSIDEFRAME, 3 , RGB(0, 0, 0) Extern.SetROP2 hDC, 6 ' hDC, R2_NOT Extern.SelectObject hDC, hPen ' Use an empty fill Extern.SelectObject hDC, Extern.GetStockObject (5) ' NULL_BRUSH ' Do the highlight For i = 0 to Times * 2 + 1 Extern.Rectangle hDC, X, Y, X + W, Y + H wait 0, 50 Next ' CleanUp Extern.ReleaseDC Extern.GetDesktopWindow, hDC Extern.DeleteObject hPen End Function
QTP本身也封装了对象的Highlight方法,可以通过object.Highlight 来调用。
相关文章推荐
- QTP 中实现对象高亮
- windows下调用系统API实现进程创建和文件读写
- quartusII和ISE调用Notepad++并且实现错误高亮定位的方法
- Windows内核对象 - 通过异步程序调用(APC)实现的定时功能
- main函数中通过使用Person类和AddressBook类,创建对象、调用方法,实现以下8个功能
- 关于Java中Scanner对象的hasNext()方法对实现Readable接口的对象中的read()方法调用的探讨
- 一种调用Win95 API实现串行通信的查询方法
- javascript中数组Array对象调用不同的方法可以实现几种数据结构
- golang 调用win32 api 实现windows注销、重启、关机
- C# Windows API应用之基于FlashWindowEx实现窗口闪烁的方法
- C# Windows API应用之FlashWindowEx ——实现窗口闪烁的方法
- windows下用swig实现python调用C\C++的方法
- Android Studio Jni开发(二)实现Native调用java方法和Native调用Android API
- 利用Windows Group实现基于角色的WCF接口方法调用授权
- JS通过调用微信API实现微信支付功能的方法示例
- C# 反射-通过继承接口实现创建对象并调用方法
- 用对象模式实现QTP的远程调用
- PHP通过反射实现对象的成员方法调用
- 利用反射实现对象调用方法
- 关于Java中Scanner对象的hasNext()方法对实现Readable接口的对象中的read()方法调用的探讨