How to Set mouse cursor position to a specified point on screen in C#?

前端 未结 2 921
眼角桃花
眼角桃花 2020-12-11 07:48

How to Set mouse cursor position to a specified point on screen in C#?

am i must hacke the motherboard buffer that receive the mouse and keyboard coordinates and pre

2条回答
  •  粉色の甜心
    2020-12-11 08:38

    Get and set mouse position in Windows 10:

    Much simpler in c# .NET Framework 4.0 using Cursor.Position Property

    https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.cursor.position?view=netcore-3.1

        public static void ClickSomePoint()
        {
    
            // get mouse position
            System.Drawing.Point screenPos = System.Windows.Forms.Cursor.Position;
    
            // create X,Y point (0,0) explicitly with System.Drawing 
            System.Drawing.Point leftTop = new System.Drawing.Point(0,0);
    
            // set mouse position
            Cursor.Position = leftTop; 
            Console.WriteLine(screenPos);
        }
    

提交回复
热议问题