Friday, July 1, 2011

How to Right Click on object

Function RightClickOnObject(ByVal objObject , ByVal intItemIndex)
   On Error Resume Next
            'Variable Section Begining
                       
             Dim absx,absy,Wshshell,DivRep,Index
            'VariableSection Ending
              If IsObjectExist(objObject)  Then
                        intAbsx = objObject.GetROProperty("abs_x")
             intAbsy = objObject.GetROProperty("abs_y")
                        Set objDivRep = CreateObject("Mercury.DeviceReplay")
                        Set objWshShell = CreateObject("WScript.Shell")
                        objDivRep.MouseClick intAbsx + 1,intAbsy + 1 , 2 '2 indicates right button
                        For IntIndex = 1 to intItemIndex
                                     WshShell.sendKeys "{DOWN}"
                        Next
                        WshShell.sendKeys "{ENTER}" ' Select the menu item
                        If err.Number = 0 Then
                                    RightClickOnObj = 0
                        Else
                                    RightClickOnObj = 1
                        End If
                        Else
                                    RightClickOnObj = 1
             End If
             'WriteStepResults RightClickOnObject
            Set WshShell = nothing
            Set objDivRep = nothing
            On Error GOTO 0

End Function

No comments: