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
Windowwindow
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
MouseButtonTypewhich mouse button
clicks
intclick times
intervalInSeconds
doubleinterval 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
Windowwindow
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
MouseButtonTypewhich mouse button
intervalInSeconds
doubleinterval in seconds between clicks
Highlight(Window, params Rectangle[])
Highlight several areas
public static void Highlight(this Window window, params Rectangle[] relativeRects)
Parameters
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
WindowThe window where the search is performed
imgFileToBeFound
BitmapDataThe image to locate within the window
confidence
doubleThe 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
withinwindow
.
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
Windowwindow
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
MouseButtonTypewhich 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
Windowwindow
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
MouseButtonTypewhich 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
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
Windowwindow
imgFileToBeFound
BitmapDataThe image to locate within the window
confidence
doubleThe 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
doubletimeout 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
Windowwindow
imgFileToBeFound
BitmapDataThe image to locate within the window
confidence
doubleThe 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
doubletimeout 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
Windowwindow
imgFileToBeFound
BitmapDataThe image to locate within the window
confidence
doubleThe 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
doubletimeout in seconds
cancellationToken
CancellationTokencancellationToken
Returns
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
Windowwindow
imgFileToBeFound
BitmapDataThe image to locate within the window
confidence
doubleThe 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
doubletimeout in seconds
cancellationToken
CancellationTokencancellationToken
Returns
Exceptions
- TimeoutException
not found after timeout