How do I set the position of the mouse cursor from a Console app in C#?

后端 未结 4 800
北荒
北荒 2021-01-05 02:38

I\'ve found many articles on how to set the mouse position in a C# windows forms project - I want to do this in a console application. How can I set the abs

4条回答
  •  萌比男神i
    2021-01-05 03:24

    This is an old thread, but for the sake of completion it can be done this way...

    use System.Runtime.InteropServices;
    
    [DllImport("user32.dll")]
    static extern bool SetCursorPos(int X, int Y);
    

    then in method whatever position you wish e.g.

      SetCursorPos(500, 500);
    

提交回复
热议问题