/// <summary> /// Converts a point in client coordinates of a window to screen coordinates. /// </summary> /// <param name="hwnd">Handle to the window of the original point.</param> /// <param name="clientPoint">Point expressed in client coordinates.</param> /// <returns>Point expressed in screen coordinates.</returns> public static NPoint ClientToScreen(IntPtr hwnd, NPoint clientPoint) { NPoint localCopy = new NPoint(clientPoint); if (ClientToScreen(hwnd, ref localCopy)) return localCopy; else return new NPoint(); }
private static void InjectDoubleLeftMouseClick(IntPtr child, NPoint clientLocation) { IntPtr lParamClickLocation = MessagingMethods.MakeLParam(clientLocation.X, clientLocation.Y); MessagingMethods.PostMessage(child, WM.LBUTTONDBLCLK, new IntPtr(MK.LBUTTON), lParamClickLocation); #if DEBUG Console.WriteLine("Double left click on window #" + child.ToString() + " at " + clientLocation.ToString()); #endif }
/// <summary> /// Converts a point in screen coordinates in client coordinates relative to a window. /// </summary> /// <param name="hwnd">Handle of the window whose client coordinate system should be used.</param> /// <param name="screenPoint">Point expressed in screen coordinates.</param> /// <returns>Point expressed in client coordinates.</returns> public static NPoint ScreenToClient(IntPtr hwnd, NPoint screenPoint) { NPoint localCopy = new NPoint(screenPoint); if (ScreenToClient(hwnd, ref localCopy)) { return(localCopy); } else { return(new NPoint()); } }
/// <summary> /// Converts a point in client coordinates of a window to screen coordinates. /// </summary> /// <param name="hwnd">Handle to the window of the original point.</param> /// <param name="clientPoint">Point expressed in client coordinates.</param> /// <returns>Point expressed in screen coordinates.</returns> public static NPoint ClientToScreen(IntPtr hwnd, NPoint clientPoint) { NPoint localCopy = new NPoint(clientPoint); if (ClientToScreen(hwnd, ref localCopy)) { return(localCopy); } else { return(new NPoint()); } }
/// <summary>Returns the child control of a window corresponding to a screen location.</summary> /// <param name="parent">Parent window to explore.</param> /// <param name="scrClickLocation">Child control location in screen coordinates.</param> private static IntPtr GetRealChildControlFromPoint(IntPtr parent, NPoint scrClickLocation) { IntPtr curr = parent, child = IntPtr.Zero; do { child = WindowManagerMethods.RealChildWindowFromPoint(curr, WindowManagerMethods.ScreenToClient(curr, scrClickLocation)); if (child == IntPtr.Zero || child == curr) break; //Update for next loop curr = child; } while (true); //Safety check, shouldn't happen if (curr == IntPtr.Zero) curr = parent; return curr; }
static extern bool ScreenToClient(IntPtr hwnd, ref NPoint point);
static extern bool ClientToScreen(IntPtr hwnd, ref NPoint point);
public static extern IntPtr RealChildWindowFromPoint(IntPtr parent, NPoint point);
private static extern bool GetCursorPosInternal(out NPoint point);
/// <summary> /// Converts a point in screen coordinates in client coordinates relative to a window. /// </summary> /// <param name="hwnd">Handle of the window whose client coordinate system should be used.</param> /// <param name="screenPoint">Point expressed in screen coordinates.</param> /// <returns>Point expressed in client coordinates.</returns> public static NPoint ScreenToClient(IntPtr hwnd, NPoint screenPoint) { NPoint localCopy = new NPoint(screenPoint); if (ScreenToClient(hwnd, ref localCopy)) return localCopy; else return new NPoint(); }
private static void InjectDoubleRightMouseClick(IntPtr child, NPoint clientLocation) { IntPtr lParamClickLocation = MessagingMethods.MakeLParam(clientLocation.X, clientLocation.Y); MessagingMethods.PostMessage(child, WM.RBUTTONDBLCLK, new IntPtr(MK.RBUTTON), lParamClickLocation); #if DEBUG System.Diagnostics.Debug.WriteLine("Double right click on window #" + child.ToString() + " at " + clientLocation.ToString()); #endif }
public NPoint(NPoint copy) { X = copy.X; Y = copy.Y; }