Application
flaui.core.application.Application
Wrapper for an application which should be automated
close_timeout
property
writable
The timeout to wait to close an application gracefully.
Returns:
| Type | Description |
|---|---|
int
|
Timeout value |
exit_code
property
Fetches Exit code of the application. Exit code is only available once the application is closed/terminated.
Returns:
| Type | Description |
|---|---|
int
|
Exit code |
has_exited
property
Gets a value indicating whether the associated process has been terminated.
Returns:
| Type | Description |
|---|---|
bool
|
Exit flag |
is_store_app
property
Flag to indicate, if the application is a windows store app.
Returns:
| Type | Description |
|---|---|
bool
|
True if app is a Windows Store App else False |
main_window_handle
property
The current handle (Win32) of the application's main window. Can be IntPtr.Zero if no main window is currently available.
Returns:
| Type | Description |
|---|---|
int
|
Main handle ID |
name
property
The name of the application's process.
Returns:
| Type | Description |
|---|---|
str
|
Application process name |
process_id
property
The process id of the application
Returns:
| Type | Description |
|---|---|
int
|
Application Process ID |
__enter__()
Enter the runtime context and return the application instance.
Enables with Application() as app: usage. Launch or attach to a process inside the
with block; the application is closed and disposed automatically on exit.
Returns:
| Type | Description |
|---|---|
'Application'
|
This application instance. |
Source code in flaui/core/application.py
__exit__(exc_type, exc_value, traceback)
Exit the runtime context, gracefully closing then disposing the application.
Mirrors the C# IDisposable contract: attempts a graceful close first, then falls
back to dispose. Never raises — cleanup failures are swallowed so they cannot mask an
exception raised inside the with block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exc_type
|
Any
|
The exception type raised in the context, if any. |
required |
exc_value
|
Any
|
The exception instance raised in the context, if any. |
required |
traceback
|
Any
|
The traceback for the exception, if any. |
required |
Source code in flaui/core/application.py
attach(process)
Attaches to a given process id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process
|
Union[str, int]
|
The id/process/path of executable of the process to attach to. |
required |
attach_or_launch(process)
Attaches or launches the given process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process
|
Union[str, int]
|
The id/process/path of executable of the process to attach to. |
required |
Source code in flaui/core/application.py
close(kill_if_close_fails=True)
Closes the application. Force-closes it after a small timeout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kill_if_close_fails
|
bool
|
A flag to indicate if the process should be killed if closing fails within the timeout, defaults to True |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
Returns true if the application was closed normally and false if it could not be closed gracefully. |
Source code in flaui/core/application.py
dispose()
get_all_top_level_windows(automation)
Gets all top level windows from the application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
automation
|
Any
|
The automation object to use. |
required |
Returns:
| Type | Description |
|---|---|
List[Window]
|
Get's all top level windows form the application |
Source code in flaui/core/application.py
get_main_window(automation)
Gets the main window of the applications process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
automation
|
Any
|
The automation object to use. |
required |
Returns:
| Type | Description |
|---|---|
Window
|
The main window object as Window element or null if no main window was found within the timeout. |
Source code in flaui/core/application.py
kill()
launch(executable, arguments=None)
Launches the given executable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
executable
|
str
|
The executable to launch. |
required |
arguments
|
Optional[str]
|
Arguments to executable, defaults to None |
None
|
Source code in flaui/core/application.py
launch_store_app(app_user_model_ltd, arguments=None)
Launches a store application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_user_model_ltd
|
str
|
The app id of the application to launch. |
required |
arguments
|
Optional[str]
|
The arguments to pass to the application., defaults to None |
None
|
Source code in flaui/core/application.py
wait_while_busy(time_out=None)
Waits as long as the application is busy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_out
|
Optional[int]
|
An optional timeout in milliseconds. If null is passed, the timeout is infinite., defaults to None |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the application is idle, else False. |
Source code in flaui/core/application.py
wait_while_main_handle_is_missing(time_out=None)
Waits until the main handle is set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_out
|
Optional[int]
|
An optional timeout in milliseconds. If null is passed, the timeout is infinite., defaults to None |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if a main window handle is found, else False. |