Forum Discussion

AMITESH's avatar
AMITESH
Contributor
9 years ago

Is there is any method for long press right Click mouse action in Testcomplete

Is there is any method for long press right Click mouse action in Testcomplete.

 

As for my test Application I want to long press right Click mouse action to get the context Menu.

 

 

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    You can use Sys.Desktop.MouseDown() and .MouseUp() with the appropriate delay. The target object must be visible on the screen.

    // Get screen coordinates of the point to click, e.g. the object's center
    var p = obj.WindowToScreen(obj.Width/2, obj.Height/2);
    Sys.Desktop.MouseDown(VK_RBUTTON, p.X, p.Y); Delay(1000); // ms Sys.Desktop.MouseUp(VK_RBUTTON, p.X, p.Y);

     

    • pyatakov's avatar
      pyatakov
      Occasional Contributor

      I prefer to use this method 

       

      var p = obj.WindowToScreen(-1, -1);

       

      than this

       

      var p = obj.WindowToScreen(obj.Width/2, obj.Height/2);

       

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        pyatakov wrote:

        I prefer to use this method 

        var p = obj.WindowToScreen(-1, -1);

        than this

        var p = obj.WindowToScreen(obj.Width/2, obj.Height/2);

        These are different things. WindowToScreen handles (-1, -1) as a point 1 pixel away from the object, whereas (obj.Width/2, obj.Height/2) is the object's center point.