Setting mouse position without System.Windows.Forms

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

The reason for this is because we use a specialized .NET subset that cannot include System.Windows.Forms.

+5
source share
2 answers

oops my bad read the question too fast, understands the correct call to pInvoke

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

Source: http://www.pinvoke.net/default.aspx/user32.setcursorpos

+6
source
private void MoveCursor()
{
   // Set the Current cursor, move the cursor 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);
}
-2
source

All Articles