Class
Window

For internal use only.

Definition

Namespace:ArtOfTest.Common.Win32

Assembly:ArtOfTest.WebAii.dll

Syntax:

cs-api-definition
public class Window

Inheritance: objectWindow

Derived Classes: Button

Constructors

Window(IntPtr)

Constructs a new instance of this class for the specified Window Handle.

Declaration

cs-api-definition
public Window(IntPtr hWnd)

Parameters

hWnd

IntPtr

The Window Handle

Fields

_process

The process owner of this window.

Declaration

cs-api-definition
protected Process _process

Field Value

Process

Properties

AllChildren

Gets a collection of all child windows (at any level) of this window.

Declaration

cs-api-definition
public virtual WindowCollection AllChildren { get; }

Property Value

WindowCollection

Caption

Gets the window's caption.

Declaration

cs-api-definition
public virtual string Caption { get; }

Property Value

string

ClassName

Gets the window's class name.

Declaration

cs-api-definition
public virtual string ClassName { get; }

Property Value

string

Enabled

Gets whether this window is enabled or not.

Declaration

cs-api-definition
public virtual bool Enabled { get; }

Property Value

bool

Exists

Gets whether the window handle represents a live native window.

Declaration

cs-api-definition
public virtual bool Exists { get; }

Property Value

bool

Handle

Gets the handle of the window.

Declaration

cs-api-definition
public virtual IntPtr Handle { get; }

Property Value

IntPtr

IsDialog

Gets whether this Window is a dialog

Declaration

cs-api-definition
public virtual bool IsDialog { get; }

Property Value

bool

IsForegroundWindow

Gets whether the window is currently in use by the user.

Declaration

cs-api-definition
public virtual bool IsForegroundWindow { get; }

Property Value

bool

IsMaximized

Gets whether the window is maximized.

Declaration

cs-api-definition
public virtual bool IsMaximized { get; }

Property Value

bool

IsMinimized

Gets whether the window is minimized.

Declaration

cs-api-definition
public virtual bool IsMinimized { get; }

Property Value

bool

IsVisible

Gets whether the window is visible.

Declaration

cs-api-definition
public virtual bool IsVisible { get; }

Property Value

bool

Location

Gets the top left point of the location of the window relative to the screen.

Declaration

cs-api-definition
public Point Location { get; }

Property Value

Point

OwnerProcess

The owner process that created this window.

Declaration

cs-api-definition
public Process OwnerProcess { get; }

Property Value

Process

ParentWindow

Get parent window of this window. Returns null if there is no parent window.

Declaration

cs-api-definition
public virtual Window ParentWindow { get; }

Property Value

Window

Rectangle

Gets the rectangle of the window.

Declaration

cs-api-definition
public Rectangle Rectangle { get; }

Property Value

Rectangle

Size

Gets the size of the window.

Declaration

cs-api-definition
public Size Size { get; }

Property Value

Size

Methods

AttachWrappedWindow()

Attach to the wrapper window handle. This call is needed to allow for events to fire on this window.

Declaration

cs-api-definition
public virtual void AttachWrappedWindow()

Remarks

The window attached to must be in the same process as this window object for it to intercept its messages and fire its events

Center()

Get the center point of this window

Declaration

cs-api-definition
public Point Center()

Returns

Point

Close()

Close the window.

Declaration

cs-api-definition
public virtual void Close()

ContainsControl(int)

Returns true/false whether the Win32 control id is a child of this window

Declaration

cs-api-definition
public virtual bool ContainsControl(int controlId)

Parameters

controlId

int

The control id.

Returns

bool

True/False whether the control exits

ContainsText(string, bool)

Returns true/false whether the text is present within this window.

Declaration

cs-api-definition
public virtual bool ContainsText(string text, bool refreshChildren)

Parameters

text

string

The text to check.

refreshChildren

bool

True/False whether to refresh the Children of this window or simply use the cached collection.

Returns

bool

True/False whether the text exists.

DetachWrappedWindow()

Detach from the window handle.

Declaration

cs-api-definition
public void DetachWrappedWindow()

EnumHwndAncestors(HWND)

Declaration

cs-api-definition
public static IEnumerable<HWND> EnumHwndAncestors(HWND hwnd)

Parameters

hwnd

HWND

Returns

IEnumerable<HWND>

GetBitmap()

Returns a bitmap

Declaration

cs-api-definition
public Bitmap GetBitmap()

Returns

Bitmap

GetBitmap(RectangleF)

Returns a bitmap of a specified target area within this window.

Declaration

cs-api-definition
public Bitmap GetBitmap(RectangleF targetArea)

Parameters

targetArea

RectangleF

The target area to return the bitmap for.

Returns

Bitmap

The bitmap of that target area as it appears in the window.

GetBitmap(Size)

Capture the entire window bitmap and returns it.

Declaration

cs-api-definition
public virtual Bitmap GetBitmap(Size windowSize)

Parameters

windowSize

Size

Returns

Bitmap

A bitmap of the window, otherwise will return null

GetHashCode()

The hash code is the window's hwnd.

Declaration

cs-api-definition
public override int GetHashCode()

Returns

int

The Window Handle of this window

Overrides object.GetHashCode()

GetText()

Get the text contained in this window and all its children windows.

Declaration

cs-api-definition
public virtual string GetText()

Returns

string

Returns a text concatenation of this window and all its children

GetWindowText()

Get current text of the window.

Declaration

cs-api-definition
public virtual string GetWindowText()

Returns

string

Current text of the window.

Hide()

Hide the window.

Declaration

cs-api-definition
public virtual void Hide()

IsHwndDialog(HWND)

Gets whether the provided window handle represents a dialog

Declaration

cs-api-definition
public static bool IsHwndDialog(HWND hwnd)

Parameters

hwnd

HWND

Returns

bool

MakeAbsolute(Rectangle)

Return the absolute coordinate of the relative rectangle.

Declaration

cs-api-definition
public Rectangle MakeAbsolute(Rectangle windowRelativeRects)

Parameters

windowRelativeRects

Rectangle

The relative rectangle with respect to this window.

Returns

Rectangle

The absolute

MakeRelative(Rectangle)

Make the absolute rects passed in relative to this window.

Declaration

cs-api-definition
public Rectangle MakeRelative(Rectangle absoluteRects)

Parameters

absoluteRects

Rectangle

The absolute rects

Returns

Rectangle

The relative coordinates to this window.

Maximize()

Maximize the window

Declaration

cs-api-definition
public virtual void Maximize()

Minimize()

Minimize the window.

Declaration

cs-api-definition
public virtual void Minimize()

Move(Rectangle, bool)

Move this window to a new location

Declaration

cs-api-definition
public virtual void Move(Rectangle newLocation, bool redraw)

Parameters

newLocation

Rectangle

The new location to move the window to.

redraw

bool

True/False whether to redraw the window.

OnClick()

For internal use only.

Declaration

cs-api-definition
protected virtual void OnClick()

OnDoubleClick()

For internal use only.

Declaration

cs-api-definition
protected virtual void OnDoubleClick()

OnKeyDown(KeyEventArgs)

For internal use only.

Declaration

cs-api-definition
protected virtual void OnKeyDown(KeyEventArgs e)

Parameters

e

KeyEventArgs

A KeyEventArgs that contains the event data.

OnKeyPressed(KeyPressEventArgs)

For internal use only.

Declaration

cs-api-definition
protected virtual void OnKeyPressed(KeyPressEventArgs e)

Parameters

e

KeyPressEventArgs

A KeyPressEventArgs that contains the event data.

OnKeyUp(KeyEventArgs)

For internal use only.

Declaration

cs-api-definition
protected virtual void OnKeyUp(KeyEventArgs e)

Parameters

e

KeyEventArgs

OnMouseClick(MouseButtons, int, int, int)

For internal use only.

Declaration

cs-api-definition
protected virtual void OnMouseClick(MouseButtons button, int clicks, int x, int y)

Parameters

button

MouseButtons

A MouseButtons that specifiesd which mouse button is associated with this event.

clicks

int

An int specifying the number of times the mouse button was pressed and released.

x

int

The x-coordinate in pixels of the mouse during the generating mouse event.

y

int

The y-coordinate in pixels of the mouse during the generating mouse event.

OnMouseClick(MouseEventArgs)

For internal use only.

Declaration

cs-api-definition
protected virtual void OnMouseClick(MouseEventArgs e)

Parameters

e

MouseEventArgs

A MouseEventArgs that contains the event data.

OnMouseDoubleClick(MouseButtons, int, int, int)

For internal use only.

Declaration

cs-api-definition
protected virtual void OnMouseDoubleClick(MouseButtons button, int clicks, int x, int y)

Parameters

button

MouseButtons

A MouseButtons that specifiesd which mouse button is associated with this event.

clicks

int

An int specifying the number of times the mouse button was pressed and released.

x

int

The x-coordinate in pixels of the mouse during the generating mouse event.

y

int

The y-coordinate in pixels of the mouse during the generating mouse event.

OnMouseDown(MouseButtons, int, int)

For internal use only.

Declaration

cs-api-definition
protected virtual void OnMouseDown(MouseButtons button, int x, int y)

Parameters

button

MouseButtons

A MouseButtons that specifiesd which mouse button is associated with this event.

x

int

The x-coordinate in pixels of the mouse during the generating mouse event.

y

int

The y-coordinate in pixels of the mouse during the generating mouse event.

OnMouseDown(MouseEventArgs)

For internal use only.

Declaration

cs-api-definition
protected virtual void OnMouseDown(MouseEventArgs e)

Parameters

e

MouseEventArgs

A MouseEventArgs that contains the event data.

OnMouseMove(int, int)

For internal use only.

Declaration

cs-api-definition
protected virtual void OnMouseMove(int x, int y)

Parameters

x

int

The x-coordinate in pixels of the mouse during the generating mouse event.

y

int

The y-coordinate in pixels of the mouse during the generating mouse event.

OnMouseUp(MouseButtons, int, int)

For internal use only.

Declaration

cs-api-definition
protected virtual void OnMouseUp(MouseButtons button, int x, int y)

Parameters

button

MouseButtons

A MouseButtons that specifiesd which mouse button is associated with this event.

x

int

The x-coordinate in pixels of the mouse during the generating mouse event.

y

int

The y-coordinate in pixels of the mouse during the generating mouse event.

OnMouseUp(MouseEventArgs)

For internal use only.

Declaration

cs-api-definition
protected virtual void OnMouseUp(MouseEventArgs e)

Parameters

e

MouseEventArgs

A MouseEventArgs that contains the event data.

OnPreMouseClick(MouseEventArgs)

For internal use only.

Declaration

cs-api-definition
protected virtual void OnPreMouseClick(MouseEventArgs e)

Parameters

e

MouseEventArgs

A MouseEventArgs that contains the event data.

OnPreMouseDown(MouseEventArgs)

For internal use only.

Declaration

cs-api-definition
protected virtual void OnPreMouseDown(MouseEventArgs e)

Parameters

e

MouseEventArgs

A MouseEventArgs that contains the event data.

OnPreMouseUp(MouseEventArgs)

For internal use only.

Declaration

cs-api-definition
protected void OnPreMouseUp(MouseEventArgs e)

Parameters

e

MouseEventArgs

A MouseEventArgs that contains the event data.

OnWindowMoved()

For internal use only.

Declaration

cs-api-definition
protected virtual void OnWindowMoved()

RefreshChildren()

Refresh the list of child windows (Window.Children) of this window

Declaration

cs-api-definition
public virtual void RefreshChildren()

Restore()

Restore the window to its default size/location

Declaration

cs-api-definition
public virtual void Restore()

SetActive()

Set this window to active.

Declaration

cs-api-definition
public virtual void SetActive()

SetFocus()

Restores and Brings the window to the front, assuming it is a visible application window.

Declaration

cs-api-definition
public virtual void SetFocus()

SetPosition(WindowPosition)

Declaration

cs-api-definition
public virtual void SetPosition(WindowPosition position)

Parameters

position

WindowPosition

Show()

Show this window and make it visible

Declaration

cs-api-definition
public virtual void Show()

Update()

Update the window. Invalidates all areas and forces a redraw.

Declaration

cs-api-definition
public virtual void Update()

WaitForVisibility(bool, int)

Waits for a certain visibility state for a window

Declaration

cs-api-definition
public void WaitForVisibility(bool visibilityState, int timeout)

Parameters

visibilityState

bool

The visibility state of the window to wait for. True: wait until window is visible (The window needs to have its handle created before calling this method), False, wait until window is invisible.

timeout

int

The wait timeout in msecs.

WaitForVisibility(bool, int, bool)

Waits for a certain visibility state for a window

Declaration

cs-api-definition
public bool WaitForVisibility(bool visibilityState, int timeout, bool suppressException)

Parameters

visibilityState

bool

The visibility state of the window to wait for. True: wait until window is visible (The window needs to have its handle created before calling this method), False, wait until window is invisible.

timeout

int

The wait timeout in msecs.

suppressException

bool

Whether to throw or return false if the window does not reach the desired visibility state.

Returns

bool

Events

Click

For internal use only.

Declaration

cs-api-definition
public event EventHandler Click

Event Value

EventHandler

DoubleClick

For internal use only.

Declaration

cs-api-definition
public event EventHandler DoubleClick

Event Value

EventHandler

KeyDown

For internal use only.

Declaration

cs-api-definition
public event KeyEventHandler KeyDown

Event Value

KeyEventHandler

KeyPressed

For internal use only.

Declaration

cs-api-definition
public event KeyPressEventHandler KeyPressed

Event Value

KeyPressEventHandler

KeyUp

For internal use only.

Declaration

cs-api-definition
public event KeyEventHandler KeyUp

Event Value

KeyEventHandler

MouseClick

For internal use only.

Declaration

cs-api-definition
public event MouseEventHandler MouseClick

Event Value

MouseEventHandler

MouseDoubleClick

For internal use only.

Declaration

cs-api-definition
public event MouseEventHandler MouseDoubleClick

Event Value

MouseEventHandler

MouseDown

For internal use only.

Declaration

cs-api-definition
public event MouseEventHandler MouseDown

Event Value

MouseEventHandler

MouseMove

For internal use only.

Declaration

cs-api-definition
public event MouseEventHandler MouseMove

Event Value

MouseEventHandler

MouseUp

For internal use only.

Declaration

cs-api-definition
public event MouseEventHandler MouseUp

Event Value

MouseEventHandler

PreMouseClick

For internal use only.

Declaration

cs-api-definition
public event MouseEventHandler PreMouseClick

Event Value

MouseEventHandler

PreMouseDown

For internal use only.

Declaration

cs-api-definition
public event MouseEventHandler PreMouseDown

Event Value

MouseEventHandler

PreMouseUp

For internal use only.

Declaration

cs-api-definition
public event MouseEventHandler PreMouseUp

Event Value

MouseEventHandler

WindowMoved

For internal use only.

Declaration

cs-api-definition
public event EventHandler WindowMoved

Event Value

EventHandler

Operators

implicit operator HWND(Window)

Declaration

cs-api-definition
public static implicit operator HWND(Window window)

Parameters

window

Window

Returns

HWND

implicit operator Window(HWND)

Declaration

cs-api-definition
public static implicit operator Window(HWND hWnd)

Parameters

hWnd

HWND

Returns

Window