Table of Contents

Class WindowExtensions

Namespace
NetAutoGUI
Assembly
NetAutoGUI.dll
public static class WindowExtensions
Inheritance
WindowExtensions
Inherited Members

Methods

Click(Window, int?, int?, MouseButtonType, int, double)

Simulate a single mouse click at the given position relative to the given windowwindow.

public static void Click(this Window window, int? winX = null, int? winY = null, MouseButtonType button = MouseButtonType.Left, int clicks = 1, double intervalInSeconds = 0)

Parameters

window Window

window

winX int?

mouse x to window origin. The default value is current mouse x.

winY int?

mouse y to window origin. The default value is current mouse y.

button MouseButtonType

which mouse button

clicks int

click times

intervalInSeconds double

interval in seconds between clicks

DoubleClick(Window, int?, int?, MouseButtonType, double)

Simulate a double mouse click at the given position relative to the given windowwindow.

public static void DoubleClick(this Window window, int? winX = null, int? winY = null, MouseButtonType button = MouseButtonType.Left, double intervalInSeconds = 0)

Parameters

window Window

window

winX int?

mouse x to window origin. The default value is current mouse x.

winY int?

mouse y to window origin. The default value is current mouse y.

button MouseButtonType

which mouse button

intervalInSeconds double

interval in seconds between clicks

Highlight(Window, params Rectangle[])

Highlight several areas

public static void Highlight(this Window window, params Rectangle[] relativeRects)

Parameters

window Window

window

relativeRects Rectangle[]

multiple areas to highlight

LocateAll(Window, BitmapData, double)

Locates all occurrences of a given bitmap within the window with a specified confidence level.

public static Rectangle[] LocateAll(this Window window, BitmapData imgFileToBeFound, double confidence = 0.99)

Parameters

window Window

The window where the search is performed

imgFileToBeFound BitmapData

The image to locate within the window

confidence double

The confidence level required for a match, ranging from 0.0 to 1.0. A value closer to 1.0 ensures higher accuracy but may result in fewer matches.

Returns

Rectangle[]

An array of Rectangle objects, each representing a located instance of imgFileToBeFound within window.

MouseDown(Window, int?, int?, MouseButtonType)

Press down a mouse key down on a window

public static void MouseDown(this Window window, int? winX = null, int? winY = null, MouseButtonType button = MouseButtonType.Left)

Parameters

window Window

window

winX int?

x to the window. Default value is the current mouse position.

winY int?

y to the window. Default value is the current mouse position.

button MouseButtonType

which button

MouseUp(Window, int?, int?, MouseButtonType)

Release a mouse key down on a window

public static void MouseUp(this Window window, int? winX = null, int? winY = null, MouseButtonType button = MouseButtonType.Left)

Parameters

window Window

window

winX int?

x to the window. Default value is the current mouse position.

winY int?

y to the window. Default value is the current mouse position.

button MouseButtonType

which button

MoveMouseTo(Window, int, int)

Move the mouse cursor to the specific location

public static void MoveMouseTo(this Window window, int winX, int winY)

Parameters

window Window

window

winX int
winY int

Wait(Window, BitmapData, double, double)

Wait for the first matched area(matched withimgFileToBeFound)

public static Rectangle Wait(this Window window, BitmapData imgFileToBeFound, double confidence = 0.99, double timeoutSeconds = 5)

Parameters

window Window

window

imgFileToBeFound BitmapData

The image to locate within the window

confidence double

The confidence level required for a match, ranging from 0.0 to 1.0. A value closer to 1.0 ensures higher accuracy but may result in fewer matches.

timeoutSeconds double

timeout in seconds

Returns

Rectangle

Rectangle of the first found area relative to window

Exceptions

TimeoutException

not found after timeout

WaitAndClick(Window, BitmapData, double, double)

Wait for the first matched area(matched withimgFileToBeFound) and click the centre of the area

public static void WaitAndClick(this Window window, BitmapData imgFileToBeFound, double confidence = 0.99, double timeoutSeconds = 5)

Parameters

window Window

window

imgFileToBeFound BitmapData

The image to locate within the window

confidence double

The confidence level required for a match, ranging from 0.0 to 1.0. A value closer to 1.0 ensures higher accuracy but may result in fewer matches.

timeoutSeconds double

timeout in seconds

Exceptions

TimeoutException

not found after timeout

WaitAndClickAsync(Window, BitmapData, double, double, CancellationToken)

Wait for the first matched area(matched withimgFileToBeFound) and click the centre of the area

public static Task WaitAndClickAsync(this Window window, BitmapData imgFileToBeFound, double confidence = 0.99, double timeoutSeconds = 5, CancellationToken cancellationToken = default)

Parameters

window Window

window

imgFileToBeFound BitmapData

The image to locate within the window

confidence double

The confidence level required for a match, ranging from 0.0 to 1.0. A value closer to 1.0 ensures higher accuracy but may result in fewer matches.

timeoutSeconds double

timeout in seconds

cancellationToken CancellationToken

cancellationToken

Returns

Task

Exceptions

TimeoutException

not found after timeout

WaitAsync(Window, BitmapData, double, double, CancellationToken)

Wait for the first matched area(matched withimgFileToBeFound)

public static Task<Rectangle> WaitAsync(this Window window, BitmapData imgFileToBeFound, double confidence = 0.99, double timeoutSeconds = 5, CancellationToken cancellationToken = default)

Parameters

window Window

window

imgFileToBeFound BitmapData

The image to locate within the window

confidence double

The confidence level required for a match, ranging from 0.0 to 1.0. A value closer to 1.0 ensures higher accuracy but may result in fewer matches.

timeoutSeconds double

timeout in seconds

cancellationToken CancellationToken

cancellationToken

Returns

Task<Rectangle>

Rectangle of the first found area

Exceptions

TimeoutException

not found after timeout