Show / Hide Table of Contents

Struct screen

Represents a screen device. Gets its rectangle etc.

public struct screen : IEquatable<screen>
Remarks

A computer can have one or more screens (aka display devices, monitors). One of them is the primary screen; its top-left coordinate is 0 0. To show or find a window or some object in a particular screen, need to identify the screen somehow. At Windows API level each screen has a unique integer identifier, known as screen handle or HMONITOR. But it is a random variable value and therefore cannot be specified directly in script etc. Instead can be used screen index or some object on that screen (window, point, rectangle).

A screen variable can contain either a screen handle or a callback function that returns a screen handle. If empty, most functions interpret it as the primary screen.

To create screen variables use static functions (like screen.index(1) or screen.primary) or constructors (like new screen(()=>screen.index(1))) or screen.at. Then call non-static functions to get screen properties.

A screen handle cannot be reliably used for a long time. Screen handles may change when changing the configuration of multiple screens. Consider a "lazy" variable, ie with callback function screen.LazyFunc. Then, whenever a function needs a screen handle, it calls the callback function which returns a screen with fresh handle.


Namespace: Au
Assembly: Au.dll

Constructors

Name Description
screen(Func<screen>)

Creates "lazy" variable that calls your function to get screen when need.

screen(nint)

Creates variable with screen handle, aka HMONITOR.

Properties

Name Description
Dpi

Gets DPI of this screen. Calls Dpi.OfScreen.

Handle

Gets the screen handle, aka HMONITOR. Returns default(IntPtr) if it wasn't set; see screen.Now.

Info

Gets screen rectangle and other info.

IsAlive

True if the screen handle is valid.

IsEmpty

Returns true if this variable has no screen handle and no callback function.

LazyFunc

Gets the callback function that returns screen when need. Returns null if it wasn't set.

Now

Returns a copy of this variable with screen.Handle.

Rect

Calls screen.Info and returns screen rectangle.

ScreenIndex

Gets index of this screen in the screen.all array.

WorkArea

Calls screen.Info and returns work area rectangle.

all

Gets all screens.

ofActiveWindow

Returns a lazy screen variable that later will get the screen of the active window at that time.

ofMouse

Returns a lazy screen variable that later will get the screen from the mouse cursor position at that time.

primary

Gets the primary screen.

virtualScreen

Gets bounding rectangle of all screens.

Methods

Name Description
Equals(screen)
Equals(object)
GetHashCode()
GetRect(bool)

Calls screen.Info and returns rectangle of the screen or its work area.

ToString()
index(int, bool)

Gets screen at the specified index of the screen.all array.

isInAnyScreen(POINT)

Returns true if point p is in some screen.

isInAnyScreen(RECT)

Returns true if rectangle r intersects with some screen.

isInAnyScreen(wnd)

Returns true if rectangle of window w intersects with some screen.

of(POINT, SODefault, bool)

Gets screen containing the specified point or nearest to it.

of(RECT, SODefault, bool)

Gets screen containing the biggest part of the specified rectangle or nearest to it.

of(wnd, SODefault, bool)

Gets screen containing the biggest part of the specified window or nearest to it.

of(wndFinder, SODefault, bool)

Gets screen containing the biggest part of the specified window or nearest to it.

of(int, int, SODefault, bool)

Gets screen containing the specified point or nearest to it.

of(Control, SODefault, bool)

Gets screen containing the biggest part of the specified winforms window or control or nearest to it.

of(FrameworkElement, SODefault, bool)

Gets screen containing the biggest part of the specified WPF element (of its rectangle) or nearest to it.

of(Window, SODefault, bool)

Gets screen containing the biggest part of the specified WPF window or nearest to it.

Operators

Name Description
operator ==(screen, screen)
operator !=(screen, screen)