|
各位高手好,写了一个.vbs文件如下:
Option Explicit
RegisterUserFunc "Window","SelectMenuItem","MySelectMenuItem"
Public Sub MySelectMenuItem(ByVal obj,ByVal sMenuItem)
Dim sSendKey,oShell
Select Case LCase(sMenuItem)
Case "about notepad": sSendKey="%ha"
Case else
Reporter.ReportEvent micFail,"SelectMenuItem","错啦"
Exit Sub
end Select
Set oShell=CreateObject("WScript.Shell")
oShell.SendKeys sSendKey
Set oShell=nothing
End Sub
在QTP中调用该文件,代码如下:
Dim oShell
Set oShell=CreateObject("WScript.Shell")
oShell.run "notepad.exe"
oShell.AppActivate "无标题-记事本"
wait 10
Window("title:=记事本").SelectMenuItem("about notepad")
Set oShell=nothing
这样可以运行成功,但是去掉vbs文件的参数ByVal obj,运行到Select case这句时,就会提示“参数不支持该属性或方法”,这是为什么?个人认为sub函数没有使用obj这个参数啊!
哪位高手指点一下,刚刚开始学QTP,谢谢啦! |
|