Forum Discussion

AMITESH's avatar
AMITESH
Contributor
10 years ago
Solved

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.

 

 

6 Replies

  • 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
        Icon for Alumni rankAlumni

        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.