First Add Class (Win32.cs)
public class Win32 { [DllImport("User32.Dll")] public static extern long SetCursorPos(int x, int y); [DllImport("User32.Dll")] public static extern bool ClientToScreen(IntPtr hWnd, ref POINT point); [StructLayout(LayoutKind.Sequential)] public struct POINT { public int x; public int y; } }
Then call it from the event:
Win32.POINT p = new Win32.POINT(); px = Convert.ToInt16(txtMouseX.Text); py = Convert.ToInt16(txtMouseY.Text); Win32.ClientToScreen(this.Handle, ref p); Win32.SetCursorPos(px, py);
user3290286 Feb 22 '14 at 21:21 2014-02-22 21:21
source share