Setting mouse position without System.Windows.Forms

前端 未结 2 1840
再見小時候
再見小時候 2021-01-19 00:45

Is there a way to manipulate the mouse position without using System.Windows.Forms.Cursor? Something like interop maybe?

Reason for this is that we are using a speci

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-19 01:07

    private void MoveCursor()
    {
       // Set the Current cursor, move the cursor's Position,
       // and set its clipping rectangle to the form. 
    
       this.Cursor = new Cursor(Cursor.Current.Handle);
       Cursor.Position = new Point(Cursor.Position.X - 50, Cursor.Position.Y - 50);
       Cursor.Clip = new Rectangle(this.Location, this.Size);
    }
    

提交回复
热议问题