These methods are only supported on Windows OS.
Using the methods below, you will be able to interact with the elements of a running application.
To interact with the elements you can use selectors and specific identifiers. The table below defines the selectors that can be used to connect to an application and filter an element.
The values of these attributes in an application can be viewed using spy tools.
See more details on inspecting apps using the Accessibility Insights for Windows tool.
In addition to the above tool for inspecting the application, it is possible to use
pywinauto own method that returns the window control identifiers.
See more details in tutorial.
|class_name||Elements with this window class|
|class_name_re||Elements whose class matches this regular expression|
|parent||Elements that are children of this|
|process||Elements running in this process|
|title||Elements with this text|
|title_re||Elements whose text matches this regular expression|
|top_level_only||Top level elements only (default=True)|
|visible_only||Visible elements only (default=True)|
|enabled_only||Enabled elements only (default=False)|
|best_match||Elements with a title similar to this|
|handle||The handle of the element to return|
|ctrl_index||The index of the child element to return|
|found_index||The index of the filtered out child element to return|
|predicate_func||A user provided hook for a custom element validation|
|active_only||Active elements only (default=False)|
|control_id||Elements with this control id|
|control_type||Elements with this control type (string; for
|auto_id||Elements with this automation id (for
|framework_id||Elements with this framework id (for
|backend||Back-end name to use while searching (default=None means current active backend)|
The backend type refers to the accessibility technology supported by the application. You can choose between two available backends:
When to use each one?¶
Win32 is the backend used by default, it is often used for applications: MFC, VB6, VCL, simple WinForms controls and most old legacy applications.
UIA backend is often used for: WinForms, WPF, Store apps, Qt5 and browsers.
Some applications support both types, but they may perform differently when using them. You can use the spy tools as a reference to define which type is most appropriate for your application. See more details at this link.
Connect to an Application¶
You can connect to an instance of an open application.
It is possible to use a combination of selectors and also pass
the accessibility technology supported by the application (
In addition to the above selectors, you can also use some specific connection selectors:
- process: Process ID of the target
- handle: Window handle of the target
- path: Path used to launch the target
from botcity.core import Backend app_path = "<path to the application .exe>" # Opens the app. bot.execute(app_path) # Connecting to the application using the 'path' and 'title' selectors. bot.connect_to_app(Backend.WIN_32, path=app_path, title="Main Window Title")
// Not yet implemented.
You can search for application windows and contexts, such as a main window or a more specific one.
# Searching for the main window. main_window = bot.find_app_window(title_re="Main") # Searching for some specific window. popup_window = bot.find_app_window(title="Confirmation Window", class_name="ThunderRT6MDIForm")
// Not yet implemented
You can search for application elements using the general context or a previously found parent context.
# Searching for some specific window. popup_window = bot.find_app_window(title="Confirmation Window", class_name="ThunderRT6MDIForm") # Searching for the element that is in the context of the found window. btn_continue = bot.find_app_element(from_parent_window=popup_window, title="Continue", class_name="ThunderRT6CommandButton") # Performing some operations with the found element. btn_continue.click()
// Not yet implemented.
How easy it is to inspect and find element properties directly depends on the application's structure. In some cases, to retain control of the main window after an action in a secondary window, it will be necessary to redeclare the main window to regain control over it.
The Application module is based on the functionalities of the
see more details about the methods available for each different type of element at