Table of Contents

Interface IApplicationController

Namespace
NetAutoGUI
Assembly
NetAutoGUI.dll

A controller for control processes and windows

public interface IApplicationController

Methods

FindWindow(Func<Window, bool>)

Find a window using the given criteria

Window? FindWindow(Func<Window, bool> predict)

Parameters

predict Func<Window, bool>

the criteria

Returns

Window

the first found window

FindWindowById(long)

Find a window by its id/handler

Window? FindWindowById(long id)

Parameters

id long

Returns

Window

the found window

FindWindowByTitle(string)

Find the first window with the given title.

Window? FindWindowByTitle(string title)

Parameters

title string

the title of the window

Returns

Window

The first found window

FindWindowLikeTitle(string)

Find a window with a given title using wildcard

Window? FindWindowLikeTitle(string wildcard)

Parameters

wildcard string

the wildcard expression. it supports * and ?. For example: notepad, n?te

Returns

Window

the first found window

GetAllWindows()

Get all opened windows.

Window[] GetAllWindows()

Returns

Window[]

all opend windows

IsApplicationRunning(string, string?)

Check if there is any processes running with the given process name

bool IsApplicationRunning(string processName, string? arguments = null)

Parameters

processName string

the process's name.

arguments string

arguments

Returns

bool

true: the application is running; false: the application is not running

KillProcesses(string)

Kill all processes with the given name

void KillProcesses(string processName)

Parameters

processName string

the process's name.

LaunchApplication(string, string?)

Launch an application

Process LaunchApplication(string appPath, string? arguments = null)

Parameters

appPath string

the path to the application

arguments string

arguments passed to the application

Returns

Process

the Process object associated with the started application

OpenFileWithDefaultApp(string)

Open the given file with the default application

void OpenFileWithDefaultApp(string filePath)

Parameters

filePath string

the file path to be opened

WaitForApplication(string, double)

Wait for the first process with the give name running.

Process WaitForApplication(string processName, double timeoutSeconds = 5)

Parameters

processName string

the process's name.

timeoutSeconds double

timeout in second

Returns

Process

the first found process

Exceptions

TimeoutException

thrown when time is up

WaitForApplicationAsync(string, double, CancellationToken)

Wait for the first process with the give name running.

Task<Process> WaitForApplicationAsync(string processName, double timeoutSeconds = 5, CancellationToken cancellationToken = default)

Parameters

processName string

the process's name.

timeoutSeconds double

timeout in second

cancellationToken CancellationToken

cancellationToken

Returns

Task<Process>

the first found process

Exceptions

TimeoutException

thrown when time is up

WaitForWindow(Func<Window, bool>, string, double)

Wait for a window using the given criteria

Window WaitForWindow(Func<Window, bool> predict, string errorMessageWhenTimeout, double timeoutSeconds = 5)

Parameters

predict Func<Window, bool>

the condition

errorMessageWhenTimeout string

errorMessageWhenTimeout

timeoutSeconds double

timeout in second

Returns

Window

the first found window

Exceptions

TimeoutException

thrown when time is up

WaitForWindowAsync(Func<Window, bool>, string, double, CancellationToken)

Wait for a window using the given criteria

Task<Window> WaitForWindowAsync(Func<Window, bool> predict, string errorMessageWhenTimeout, double timeoutSeconds = 5, CancellationToken cancellationToken = default)

Parameters

predict Func<Window, bool>

the condition

errorMessageWhenTimeout string

errorMessageWhenTimeout

timeoutSeconds double

timeout in second

cancellationToken CancellationToken

cancellationToken

Returns

Task<Window>

the first found window

Exceptions

TimeoutException

thrown when time is up

WaitForWindowByTitle(string, double)

Wait for the window with the given title

Window WaitForWindowByTitle(string title, double timeoutSeconds = 5)

Parameters

title string

title

timeoutSeconds double

timeout in second

Returns

Window

The first found window

Exceptions

TimeoutException

thrown when time is up

WaitForWindowByTitleAsync(string, double, CancellationToken)

Wait for the window with the given title

Task<Window> WaitForWindowByTitleAsync(string title, double timeoutSeconds = 5, CancellationToken cancellationToken = default)

Parameters

title string

title

timeoutSeconds double

timeout in second

cancellationToken CancellationToken

cancellationToken

Returns

Task<Window>

The first found window

Exceptions

TimeoutException

thrown when time is up

WaitForWindowLikeTitle(string, double)

Wait for a window using the given wildcard title

Window WaitForWindowLikeTitle(string wildcard, double timeoutSeconds = 5)

Parameters

wildcard string

the wildcard expression. it supports * and ?. For example: notepad, n?te

timeoutSeconds double

timeout in second

Returns

Window

the first found window

Exceptions

TimeoutException

thrown when time is up

WaitForWindowLikeTitleAsync(string, double, CancellationToken)

Wait for a window using the given wildcard title

Task<Window> WaitForWindowLikeTitleAsync(string wildcard, double timeoutSeconds = 5, CancellationToken cancellationToken = default)

Parameters

wildcard string

the wildcard expression. it supports * and ?. For example: notepad, n?te

timeoutSeconds double

timeout in second

cancellationToken CancellationToken

cancellationToken

Returns

Task<Window>

the first found window

Exceptions

TimeoutException

thrown when time is up