51Testing软件测试论坛

标题: 模拟键盘操作的(还能模拟鼠标右键,选中“save as”) [打印本页]

作者: rivermen    时间: 2007-5-16 16:28
标题: 模拟键盘操作的(还能模拟鼠标右键,选中“save as”)
转载自 http://www.17testing.com

'UI_object : The object on UI which you want to right click the mouse.
'Menu_index : the menu's index, which one you want to select
Function RightMouseAction( UI_object, Menu_index)
        Set obj = CreateObject("Mercury.DeviceReplay")
        Set WshShell = CreateObject("WScript.Shell")

                'Get the absolute coordinates of the ibject
        absx = UI_object.QueryValue("abs_x")
        absy = UI_object.QueryValue("abs_y")         

        obj.MouseClick absx+3, absy+3, 2
        'Optional wait statement
        wait(2)
        'Menu_index = 4
        For i = 1 To Menu_index
                WshShell.sendkeys "{DOWN}"
                wait(1)
        Next
        WshShell.sendkeys "{ENTER}"
        Set WshSEll = nothing
        Set obj = nothing
End Function

测试过可以用,同时把我测试的脚本上传,希望对你有帮助
[attach]25435[/attach]
作者: stone821021    时间: 2007-5-16 16:34
海军的脚本这么快就让人转帖出来了!sdlkfj3




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2