Class
WindowManager

Provides basic Win32 window management services like searching ...etc.

Definition

Namespace:ArtOfTest.Common.Win32

Assembly:ArtOfTest.WebAii.dll

Syntax:

cs-api-definition
public class WindowManager

Inheritance: objectWindowManager

Constructors

WindowManager()

Create a new window manager

Declaration

cs-api-definition
public WindowManager()

Properties

IEInstances

Declaration

cs-api-definition
public static List<Window> IEInstances { get; }

Property Value

List<Window>

Items

Returns the collection of windows populated by a call to GetWindows()

Declaration

cs-api-definition
public WindowCollection Items { get; }

Property Value

WindowCollection

VisibleWindowsOnly

Gets or sets whether to filter window to visible windows only. Default is false.

Declaration

cs-api-definition
public bool VisibleWindowsOnly { get; set; }

Property Value

bool

Methods

AppendWindows(IntPtr)

Append all child windows of the passed in parentHwnd to the current collection. (Items)

Declaration

cs-api-definition
public void AppendWindows(IntPtr parentHwnd)

Parameters

parentHwnd

IntPtr

The window to append children of.

CenterSize(Size, Rectangle)

Calculate the correct point (x,y) for a specific size to be centered within a specific rectangle.

Declaration

cs-api-definition
public static Point CenterSize(Size sizeToCenter, Rectangle areaToCenterIn)

Parameters

sizeToCenter

Size

The size to center

areaToCenterIn

Rectangle

The target location to center

Returns

Point

FindWindowRecursively(IntPtr, string, bool, int)

Find a window recursively using its caption.

Declaration

cs-api-definition
public static Window FindWindowRecursively(IntPtr parentHwnd, string caption, bool partialCaption, int delaySearchPeriod)

Parameters

parentHwnd

IntPtr

The parent window to search under. If Zero, will search all deskop windows.

caption

string

The caption to find.

partialCaption

bool

Use partial caption matching or exact. (In both cases the matching is case-insensitive).

delaySearchPeriod

int

The number of milli-seconds to delay the start of the search to allow the window we are searching for to be constructed. (if 0, no delay will occur)

Returns

Window

The found window or null;

FindWindowRecursively(IntPtr, string, bool, int, int)

Find a window recursively using its caption.

Declaration

cs-api-definition
public static Window FindWindowRecursively(IntPtr parentHwnd, string caption, bool partialCaption, int delaySearchPeriod, int maxDepth)

Parameters

parentHwnd

IntPtr

The parent window to search under. If Zero, will search all deskop windows.

caption

string

The caption to find.

partialCaption

bool

Use partial caption matching or exact. (In both cases the matching is case-insensitive).

delaySearchPeriod

int

The number of milli-seconds to delay the start of the search to allow the window we are searching for to be constructed. (if 0, no delay will occur)

maxDepth

int

The maximum depth level at which we will try to get the proper window.

Returns

Window

The found window or null;

FindWindowRecursively(IntPtr, string, int)

Find a window recusively under the parent window. Will return the first window that matches the class name.

Declaration

cs-api-definition
public static Window FindWindowRecursively(IntPtr parentHwnd, string className, int delaySearchPeriod)

Parameters

parentHwnd

IntPtr

The parent window to search under. If Zero, will search all desktop windows.

className

string

The class name to search for. (case-insensitive)

delaySearchPeriod

int

The number of milli-seconds to delay the start of the search to allow the window we are searching for to be constructed. (if 0, no delay will occur)

Returns

Window

The window that matches, otherwise null.

FindWindowsRecursively(IntPtr, List<string>, int, int)

Finds all windows of a given class under the parent window.

Declaration

cs-api-definition
public static IList<Window> FindWindowsRecursively(IntPtr parentHwnd, List<string> classNames, int delaySearchPeriod, int maxDepth = 2147483647)

Parameters

parentHwnd

IntPtr

The parent window to search under. If Zero, will search all desktop windows.

classNames

List<string>

A list of class names to search for (case-insensitive)

delaySearchPeriod

int

Search max depth. The number of milliseconds to delay the start of the search to allow the window we are searching for to be constructed.

maxDepth

int

Returns

IList<Window>

A list of all windows of the specified class under the parent window

GetActiveScreen()

Returns the active screen the user is using.

Declaration

cs-api-definition
public static Screen GetActiveScreen()

Returns

Screen

The active screen the user is using

GetAllWindows(Process)

Populate the Items collection with all windows associated with this process including child windows of each.

Declaration

cs-api-definition
public void GetAllWindows(Process process)

Parameters

process

Process

The process

GetProcessDialogFrameWindows(int)

Declaration

cs-api-definition
public static IEnumerable<Window> GetProcessDialogFrameWindows(int processId)

Parameters

processId

int

Returns

IEnumerable<Window>

GetWindows()

Populate the Items collection with all top level windows.

Declaration

cs-api-definition
public void GetWindows()

GetWindows(IntPtr)

Populate the Items collection with all child windows of the parent window passed in (Recursive)

Declaration

cs-api-definition
public void GetWindows(IntPtr parentHwnd)

Parameters

parentHwnd

IntPtr

The parent window.

GetWindows(Process)

Populate the Items collection with all non-child windows associated with this process.

Declaration

cs-api-definition
public void GetWindows(Process process)

Parameters

process

Process

The process

RecommendSize(Rectangle, Size)

Recommend the actual size of the window to use.

Declaration

cs-api-definition
public static Rectangle RecommendSize(Rectangle desiredSize, Size minSize)

Parameters

desiredSize

Rectangle

minSize

Size

Returns

Rectangle

TileWindows(Window, Window, TileWindowsOption, Size)

Tiles two windows

Declaration

cs-api-definition
public static void TileWindows(Window window1, Window window2, TileWindowsOption option, Size window1MinSize)

Parameters

window1

Window

The first window

window2

Window

The second window

option

TileWindowsOption

Tiling option

window1MinSize

Size

The first window minimum size.