public static void MoveCursor(int x, Int32 y, IntPtr hWnd) { Win32Cursor.Point p = new Win32Cursor.Point { x = Convert.ToInt16(x), y = Convert.ToInt16(y) }; Win32Cursor.ClientToScreen(hWnd, ref p); Win32Cursor.SetCursorPos(p.x, p.y); }
private void Timer1_Tick(object sender, EventArgs e) { // New point that will be updated by the function with the current coordinates Win32Cursor.Point currentCoordinates = new Win32Cursor.Point(); // Call the function and pass the Point Win32Cursor.GetCursorPosition(ref currentCoordinates); // Now after calling the function, defPnt contains the coordinates which we can read lblCoordX.Text = $@"X = {currentCoordinates.x}"; lblCoordY.Text = $@"Y = {currentCoordinates.y}"; }