Setting mouse position without System.Windows.Forms

ⅰ亾dé卋堺 提交于 2019-12-01 17:44:06

oops my bad, read question too fast, heres the correct PInvoke call

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

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

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);
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!