Class WindowHelper
Provides methods to interact with windows.
Inherited Members
Namespace: GameOverlay.Windows
Assembly: GameOverlay.dll
Syntax
public static class WindowHelper
Methods
| Improve this Doc View SourceEnableBlurBehind(IntPtr)
Enables the blur effect for a window and makes it translucent.
Declaration
public static void EnableBlurBehind(IntPtr hwnd)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | hwnd | A valid handle to a window. The desktop window is not supported. |
ExtendFrameIntoClientArea(IntPtr)
Extends a windows frame into the client area of the window.
Declaration
public static void ExtendFrameIntoClientArea(IntPtr hwnd)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | hwnd | A IntPtr representing the handle of a window. |
FindChildWindow(IntPtr, String, String, IntPtr)
Searches for the first child window matching the search criterias.
Declaration
public static IntPtr FindChildWindow(IntPtr parentWindow, string childWindowName = null, string childClassName = null, IntPtr childAfter = default(IntPtr))
Parameters
Type | Name | Description |
---|---|---|
IntPtr | parentWindow | A window handle. |
String | childWindowName | The window title of the child window. Can be null. |
String | childClassName | The window class of the child window. Can be null. |
IntPtr | childAfter | A handle to a child window. The search begins with the next child window in the Z order. The child window must be a direct child window of hwndParent, not just a descendant window. |
Returns
Type | Description |
---|---|
IntPtr | Returns the matching window handle or IntPtr.Zero if none matches. |
FindWindow(String, String)
Searches for the first window matching the given parameters.
Declaration
public static IntPtr FindWindow(string title, string className = null)
Parameters
Type | Name | Description |
---|---|---|
String | title | The window name. Can be null. |
String | className | The windows class name. Can be null. |
Returns
Type | Description |
---|---|
IntPtr | Returns the matching window handle or IntPtr.Zero if none matches. |
GenerateRandomClass()
Generates a random window class name.
Declaration
public static string GenerateRandomClass()
Returns
Type | Description |
---|---|
String | The string this method creates. |
GenerateRandomTitle()
Generates a random window title.
Declaration
public static string GenerateRandomTitle()
Returns
Type | Description |
---|---|
String | The string this method creates. |
GetActiveWindow()
Retrieves the window handle to the active window attached to the calling thread's message queue.
Declaration
public static IntPtr GetActiveWindow()
Returns
Type | Description |
---|---|
IntPtr | The return value is the handle to the active window attached to the calling thread's message queue. Otherwise, the return value is NULL. |
GetClassLong(IntPtr, Int32)
Retrieves the specified value from the WNDCLASSEX structure associated with the specified window.
Declaration
public static long GetClassLong(IntPtr handle, int index)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | handle | A window handle. |
Int32 | index | The index can be a byte offset or one of the defined constants. |
Returns
Type | Description |
---|---|
Int64 | If the function succeeds, the return value is the requested value. |
GetDesktopWindow()
Retrieves a handle to the desktop window. The desktop window covers the entire screen. The desktop window is the area on top of which other windows are painted.
Declaration
public static IntPtr GetDesktopWindow()
Returns
Type | Description |
---|---|
IntPtr | The return value is a handle to the desktop window. |
GetFirstChildWindow(IntPtr)
Returns the first child window of the specified parent window if it has one.
Declaration
public static IntPtr GetFirstChildWindow(IntPtr hwnd)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | hwnd | A window handle. IntPtr.Zero for the desktop window. |
Returns
Type | Description |
---|---|
IntPtr | If the function succeeds, the return value is a window handle. If no window exists with the specified relationship to the specified window, the return value is NULL. |
GetFirstWindow(IntPtr)
Returns the window with the highest position in the Z order relative (Topmost or not) to the given handle.
Declaration
public static IntPtr GetFirstWindow(IntPtr hwnd)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | hwnd | A window handle. IntPtr.Zero for the desktop window. |
Returns
Type | Description |
---|---|
IntPtr | If the function succeeds, the return value is a window handle. If no window exists with the specified relationship to the specified window, the return value is NULL. |
GetForegroundWindow()
Retrieves a handle to the foreground window (the window with which the user is currently working). The system assigns a slightly higher priority to the thread that creates the foreground window than it does to other threads.
Declaration
public static IntPtr GetForegroundWindow()
Returns
Type | Description |
---|---|
IntPtr | The return value is a handle to the foreground window. The foreground window can be NULL in certain circumstances, such as when a window is losing activation. |
GetLastWindow(IntPtr)
Returns the window with the lowest position in the Z order relative (Topmost or not) to the given handle.
Declaration
public static IntPtr GetLastWindow(IntPtr hwnd)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | hwnd | A window handle. IntPtr.Zero for the desktop window. |
Returns
Type | Description |
---|---|
IntPtr | If the function succeeds, the return value is a window handle. If no window exists with the specified relationship to the specified window, the return value is NULL. |
GetNextWindow(IntPtr)
Returns the window below the specified window in the Z order.
Declaration
public static IntPtr GetNextWindow(IntPtr hwnd)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | hwnd | A window handle. IntPtr.Zero for the desktop window. |
Returns
Type | Description |
---|---|
IntPtr | If the function succeeds, the return value is a window handle. If no window exists with the specified relationship to the specified window, the return value is NULL. |
GetOwnerWindow(IntPtr)
Returns the owner window of the specified window if it exists.
Declaration
public static IntPtr GetOwnerWindow(IntPtr hwnd)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | hwnd | A window handle. IntPtr.Zero for the desktop window. |
Returns
Type | Description |
---|---|
IntPtr | If the function succeeds, the return value is a window handle. If no window exists with the specified relationship to the specified window, the return value is NULL. |
GetPreviousWindow(IntPtr)
Returns the window above the specified window in the Z order.
Declaration
public static IntPtr GetPreviousWindow(IntPtr hwnd)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | hwnd | A window handle. IntPtr.Zero for the desktop window. |
Returns
Type | Description |
---|---|
IntPtr | If the function succeeds, the return value is a window handle. If no window exists with the specified relationship to the specified window, the return value is NULL. |
GetProcessIdFromWindow(IntPtr)
Retrieves the identifier of the process that created the window.
Declaration
public static int GetProcessIdFromWindow(IntPtr handle)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | handle | A handle to the window. |
Returns
Type | Description |
---|---|
Int32 | The return value is the identifier of the process that created the window. |
GetShellWindow()
Retrieves a handle to the Shell's desktop window.
Declaration
public static IntPtr GetShellWindow()
Returns
Type | Description |
---|---|
IntPtr | The return value is the handle of the Shell's desktop window. If no Shell process is present, the return value is NULL. |
GetWindowBounds(IntPtr, out WindowBounds)
Returns the boundaries of a window.
Declaration
public static bool GetWindowBounds(IntPtr hwnd, out WindowBounds bounds)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | hwnd | A IntPtr representing the handle of a window. |
WindowBounds | bounds | A WindowBounds structure representing the boundaries of a window. |
Returns
Type | Description |
---|---|
Boolean |
GetWindowClientBounds(IntPtr, out WindowBounds)
Returns the boundaries of a windows client area.
Declaration
public static bool GetWindowClientBounds(IntPtr hwnd, out WindowBounds bounds)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | hwnd | A IntPtr representing the handle of a window. |
WindowBounds | bounds | A WindowBounds structure representing the boundaries of a window. |
Returns
Type | Description |
---|---|
Boolean |
GetWindowClientBoundsExtra(IntPtr, out WindowBounds)
Returns the size of the client area of the window possibly with borders.
Declaration
public static bool GetWindowClientBoundsExtra(IntPtr hwnd, out WindowBounds bounds)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | hwnd | A IntPtr representing the handle of a window. |
WindowBounds | bounds | A WindowBounds structure representing the boundaries of a window. |
Returns
Type | Description |
---|---|
Boolean |
GetWindowLong(IntPtr, Int32)
Retrieves information about the specified window. The function also retrieves the value at a specified offset into the extra window memory.
Declaration
public static long GetWindowLong(IntPtr handle, int index)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | handle | A window handle. |
Int32 | index | The index can be a byte offset or one of the defined constants. |
Returns
Type | Description |
---|---|
Int64 | If the function succeeds, the return value is the requested value. |
GetWindowStyle(IntPtr, out UInt32, out UInt32)
Retrieves the style and extended style of a given window.
Declaration
public static bool GetWindowStyle(IntPtr handle, out uint style, out uint extendedStyle)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | handle | A window handle. |
UInt32 | style | Contains the window style on success. |
UInt32 | extendedStyle | Contains the extended window style on success. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the function succeeds. |
IsWindow(IntPtr)
Determines whether the specified window handle identifies an existing window.
Declaration
public static bool IsWindow(IntPtr handle)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | handle | A handle to the window to be tested. |
Returns
Type | Description |
---|---|
Boolean | Returns true when the given handle identifies an existing window. |
IsWindowVisible(IntPtr)
Determines the visibility state of the specified window.
Declaration
public static bool IsWindowVisible(IntPtr hwnd)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | hwnd | A handle to the window to be tested. |
Returns
Type | Description |
---|---|
Boolean | If the specified window, its parent window, its parent's parent window, and so forth, have the WS_VISIBLE style, the return value is nonzero. Otherwise, the return value is zero. |
MakeTopmost(IntPtr)
Adds the topmost flag to a window.
Declaration
public static void MakeTopmost(IntPtr hwnd)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | hwnd | A IntPtr representing the handle of a window. |
RemoveTopmost(IntPtr)
Removes the topmost flag from a window.
Declaration
public static void RemoveTopmost(IntPtr hwnd)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | hwnd | A IntPtr representing the handle of a window. |