// anvaka's changes below public static Point GetCursorPosition() { var pos = new Point(); var win32Point = new POINT(); if (GetCursorPos(ref win32Point)) { pos.X = win32Point.X; pos.Y = win32Point.Y; } return pos; }
private static extern IntPtr WindowFromPoint(POINT Point);
private static extern bool GetCursorPos(ref POINT pt);
public static IntPtr GetWindowUnderMouse() { POINT pt = new POINT(); if (GetCursorPos(ref pt)) { return WindowFromPoint(pt); } return IntPtr.Zero; }
private static extern IntPtr WindowFromPoint(POINT point);