/// <summary> /// Resize the specified window. /// </summary> /// <param name="hWnd">The handle to the window.</param> /// <param name="x">The width of the new size.</param> /// <param name="y">The height of the new size.</param> public static void Resize(IntPtr hWnd, int width, int height) { WinAPI.SetWindowPos(hWnd, 0, 0, 0, width, height, 0x002); }
/// <summary> /// Put focus on a window. /// </summary> /// <param name="hWnd">The handle to the window.</param> public static void SetFocused(IntPtr hWnd) { WinAPI.SetForegroundWindow(hWnd); }
/// <summary> /// Move the specified window by the top left corner. /// </summary> /// <param name="hWnd">The handle to the window.</param> /// <param name="x">The x coordinate of the new position.</param> /// <param name="y">The y coordinate of the new position.</param> public static void Move(IntPtr hWnd, int x, int y) { WinAPI.SetWindowPos(hWnd, 0, x, y, 0, 0, 0x0001); }
/// <summary> /// Allow a user to click through a window. /// </summary> /// <param name="Handle">The handle to the window.</param> public static void EnableMouseTransparency(IntPtr hWnd) { WinAPI.SetWindowLong(hWnd, -20, Convert.ToInt32(WinAPI.GetWindowLong(hWnd, -20) | 0x00080000 | 0x00000020L)); }
/// <summary> /// Get the handle of the window that is currently in focus. /// </summary> /// <returns>The handle to the focused Window.</returns> public static IntPtr GetFocused() { return(WinAPI.GetForegroundWindow()); }
/// <summary> /// Flip the layout of a window. /// </summary> /// <param name="hWnd">The handle to the window.</param> public static void FlipLeft(IntPtr hWnd) { var currentStyle = WinAPI.GetWindowLong(hWnd, -20); WinAPI.SetWindowLong(hWnd, -20, (currentStyle | (int)0x00400000L)); }
/// <summary> /// Flip the layout of a window back to its original state. /// </summary> /// <param name="hWnd">The handle to the window.</param> public static void FlipRight(IntPtr hWnd) { WinAPI.SetWindowLong(hWnd, -20, 0); }
/// <summary> /// Close a window, but prompts the option to save before closing. /// </summary> /// <param name="hWnd">The handle to the window.</param> public static void Close(IntPtr hWnd) { // fShutDown = true will kill the window instantly // fShutDown = false will show the message box before closing for Saving Changes WinAPI.EndTask(hWnd, true, true); }
/// <summary> /// Disable a window's minimize button. /// </summary> /// <param name="hWnd">The handle to the window.</param> public static void DisableMinimizeButton(IntPtr hWnd) { var currentStyle = WinAPI.GetWindowLong(hWnd, -16); WinAPI.SetWindowLong(hWnd, -16, (currentStyle & ~0x20000)); }
/// <summary> /// Minimize the specified window. /// </summary> /// <param name="hWnd">The handle to the window.</param> public static void Minimize(IntPtr hWnd) { WinAPI.ShowWindow(hWnd, 6); }
/// <summary> /// Restore the specified window to its original position if it is maximized or minimized. /// </summary> /// <param name="hWnd">The handle to the window.</param> public static void Normalize(IntPtr hWnd) { WinAPI.ShowWindow(hWnd, 1); }
/// <summary> /// Maximize the specified window. /// </summary> /// <param name="hWnd">The handle to the window.</param> public static void Maximize(IntPtr hWnd) { WinAPI.ShowWindow(hWnd, 3); }
/// <summary> /// Check if a particular window is open. /// </summary> /// <param name="windowTitle">The title of the window.</param> /// <returns>True if the window is open.</returns> public static bool DoesExist(string windowTitle) { IntPtr hWnd = WinAPI.FindWindow(null, windowTitle); return(hWnd != IntPtr.Zero); }
/// <summary> /// Change the specified window's title. /// </summary> /// <param name="hWnd">The handle to the window.</param> /// <param name="title">The new title.</param> public static void SetTitle(IntPtr hWnd, string title) { WinAPI.SetWindowText(hWnd, title); }
/// <summary> /// Show the specified hidden window. Hidden is not the same as minimized. /// For minimized windows use the normalize method instead. /// </summary> /// <param name="hWnd">The handle to the window.</param> public static void Show(IntPtr hWnd) { WinAPI.SetWindowPos(hWnd, 0, 0, 0, 0, 0, 0x0040); }
/// <summary> /// Hide the specified window. /// </summary> /// <param name="hWnd">The handle to the window.</param> public static void Hide(IntPtr hWnd) { WinAPI.SetWindowPos(hWnd, 0, 0, 0, 0, 0, 0x0080); }