Right-Clicking Objects Using Device Replay

The function below uses the DeviceReplay object to perform a right-click operation on any object by retrieving the coordinates of the object.

VBScript sample

Copy code
Sub RightClickObj(Obj, Offset_x, Offset_y)
    x_coord = Obj.GetROProperty("abs_x")
    y_coord = Obj.GetROProperty("abs_y")
    Set dr = CreateObject("Mercury.DeviceReplay")
    dr.MouseClick x_coord + Offset_x, y_coord + Offset_y, 2
End Sub

Python sample

Copy code
def right_click_obj(obj, offset_x, offset_y):
    x_coord = obj.GetROProperty("abs_x")
    y_coord = obj.GetROProperty("abs_y")
    dr = CreateObject("Mercury.DeviceReplay")
    dr.MouseClick(x_coord + offset_x, y_coord + offset_y, 2)