Search code examples
c#microsoft-ui-automation

Microsoft Automation UI mouse click on a given position


I am developing a C# console application that will open up an application and do some stuff there. I am able to launch the app and login to app. I need to do some mouse click operation on specific positions though but could not find how to do it. Is it possible to simulate it? I must use the position because I need what I want to do is not just clicking on a button or textbox. I need to do a right click on main window and choose something from the opening menu. I am not sure there is a way to do it with Microsoft Automation UI.

Thanks in advance.


Solution

  • Download Microsoft.TestApi from Nuget.

    using Microsoft.Test.Input;
    using System.Drawing;
    
    Mouse.MoveTo(new Point(1000, 1000));
    Mouse.Click(MouseButton.Right);
    

    Also, you can use Teststack.White for such automation purposes.