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
Returns
- Window
the first found window
FindWindowById(long)
Find a window by its id/handler
Window? FindWindowById(long id)
Parameters
idlong
Returns
- Window
the found window
FindWindowByTitle(string)
Find the first window with the given title.
Window? FindWindowByTitle(string title)
Parameters
titlestringthe 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
wildcardstringthe 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
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
processNamestringthe process's name.
LaunchApplication(string, string?)
Launch an application
Process LaunchApplication(string appPath, string? arguments = null)
Parameters
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
filePathstringthe 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
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
processNamestringthe process's name.
timeoutSecondsdoubletimeout in second
cancellationTokenCancellationTokencancellationToken
Returns
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
predictFunc<Window, bool>the condition
errorMessageWhenTimeoutstringerrorMessageWhenTimeout
timeoutSecondsdoubletimeout 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
predictFunc<Window, bool>the condition
errorMessageWhenTimeoutstringerrorMessageWhenTimeout
timeoutSecondsdoubletimeout in second
cancellationTokenCancellationTokencancellationToken
Returns
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
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
titlestringtitle
timeoutSecondsdoubletimeout in second
cancellationTokenCancellationTokencancellationToken
Returns
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
wildcardstringthe wildcard expression. it supports * and ?. For example: notepad, n?te
timeoutSecondsdoubletimeout 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
wildcardstringthe wildcard expression. it supports * and ?. For example: notepad, n?te
timeoutSecondsdoubletimeout in second
cancellationTokenCancellationTokencancellationToken
Returns
Exceptions
- TimeoutException
thrown when time is up