1. QTP测试对象的Type方法
举例:
Browser("Untitled").Dialog("Properties").WinButton("OK").Type micReturn
2. WSH中的SendKeys方法
举例:
Set wshobj = CreateObject("WScript.Shell")
wshobj.SendKeys "{ENTER}"
Set wshobj = Nothing
3. QTP隐藏对象Mercury.DeviceReplay
在Mercury.DeviceReplay对象下,有像SendString,PressKey,PressKeys,KeyUp和KeyDown之类的方法可以用来模拟键盘操作。
4. 调用Windows API
extern.Declare micVoid, "keybd_event", "user32", "keybd_event", micbyte, micbyte, miclong, miclong
extern.Declare micLong, "MapVirtualKey", "user32", "MapVirtualKeyA", micLong, micLong
Const