RPA.Desktop.Windows
Get machine boot time
return: | boot time in seconds from Epoch |
---|
Examples
Calculate x and y center coordinates from rectangle.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
rectangle | Any | null | element rectangle coordinates |
param rectangle: | |
---|---|
element rectangle coordinates | |
return: | x and y coordinates of rectangle center |
Examples
Mouse click on coordinates x and y.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
x | int, None | None | horizontal coordinate for click, defaults to None |
y | int, None | None | vertical coordinate for click, defaults to None |
click_type | str | click | "click", "right" or "double", defaults to "click" |
Default click type is click meaning left
param x: | horizontal coordinate for click, defaults to None |
---|---|
param y: | vertical coordinate for click, defaults to None |
param click_type: | |
"click", "right" or "double", defaults to "click" | |
raises ValueError: | |
if coordinates are not valid |
Examples
Close all applications
Examples
Connect to application by its handle
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
handle | int | null | handle of the application |
windowtitle | str, None | None | name of the window, defaults to active window if None |
existing_app | bool | False | set True if selecting window which library has already accessed, default False |
parse_elements | bool | True | set False to not to parse elements of the window, default True |
param handle: | handle of the application |
---|---|
param windowtitle: | |
name of the window, defaults to active window if None | |
param existing_app: | |
set True if selecting window which library has already accessed, default False | |
param parse_elements: | |
set False to not to parse elements of the window, default True |
Examples
Connect to application by its pid
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
app_pid | str | null | process id of the application |
windowtitle | str, None | None | name of the window, defaults to active window if None |
param app_pid: | process id of the application |
---|---|
param windowtitle: | |
name of the window, defaults to active window if None |
Examples
Drag elements from source and drop them on target.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
src | Any | null | application object or instance id |
target | Any | null | application object or instance id |
src_locator | str | null | elements to move |
target_locator | str, None | None | |
handle_ctrl_key | bool | False | True if keyword should press CTRL down dragging |
drop_delay | float | 2.0 | how many seconds to wait until releasing mouse drop, default 2.0 |
origin | str | middle |
Please note that if CTRL is not pressed down during drag and drop then operation is MOVE operation, on CTRL down the operation is COPY operation.
There will be also overwrite notification if dropping over existing files.
param src: | application object or instance id |
---|---|
param target: | application object or instance id |
param src_locator: | |
elements to move | |
param handle_ctrl_key: | |
True if keyword should press CTRL down dragging | |
param drop_delay: | |
how many seconds to wait until releasing mouse drop, default 2.0 | |
raises ValueError: | |
on validation errors |
Examples
Find element from window by locator and criteria.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
locator | str | null | name of the locator |
search_criteria | str, None | None | criteria by which element is matched |
param locator: | name of the locator |
---|---|
param search_criteria: | |
criteria by which element is matched | |
return: | list of matching elements and locators that were found on the window |
Examples
Get application object by id
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
app_id | int, None | None | id of the application to get, defaults to None |
By default returns active_application application object.
param app_id: | id of the application to get, defaults to None |
---|---|
return: | application object |
Examples
Get computer boot time in seconds from Epoch or in datetime string.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
as_datetime | bool | False | if True returns datetime string, otherwise seconds, defaults to False |
datetime_format | str | %Y-%m-%d %H:%M:%S | datetime string format, defaults to "%Y-%m-%d %H:%M:%S" |
param as_datetime: | |
---|---|
if True returns datetime string, otherwise seconds, defaults to False | |
param datetime_format: | |
datetime string format, defaults to "%Y-%m-%d %H:%M:%S" | |
return: | seconds from Epoch or datetime string |
Examples
Get dialog rectangle coordinates
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
ctrl | Any, None | None | name of the window control object, defaults to None |
as_dict | bool | False |
If ctrl is None then get coordinates from dialog
param ctrl: | name of the window control object, defaults to None |
---|---|
return: | coordinates: left, top, right, bottom |
Examples
Get element by locator.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
locator | str | null | name of the locator |
screenshot | bool | False | takes element screenshot if True, defaults to False |
open_dialog | bool | True | True if dialog should be reopened, default to True |
param locator: | name of the locator |
---|---|
param screenshot: | |
takes element screenshot if True, defaults to False | |
param open_dialog: | |
True if dialog should be reopened, default to True | |
return: | element if element was identified, else False |
Examples
Get value of element rectangle attribute.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
locator | str | null | element locator |
as_dict | bool | False | return values in a dictionary, default False |
param locator: | element locator |
---|---|
param as_dict: | return values in a dictionary, default False |
return: | (left, top, right, bottom) values if found, else False |
Examples
Get computer memory stats and return those in bytes or in humanized memory format.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
humanized | bool | True | if False returns memory information in bytes, defaults to True |
param humanized: | |
---|---|
if False returns memory information in bytes, defaults to True | |
return: | memory information in dictionary format |
Examples
Get list of all open applications
Returns a dictionary
Examples
Replace spaces in a text with pywinauto.keyboard space characters {VK_SPACE}
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
text | null | replace spaces in this string |
param text: | replace spaces in this string |
---|
Examples
Get element information about all window dialog controls and their descendants.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
screenshot | bool | False | save element screenshot if True, defaults to False |
element_json | bool | False | save element json if True, defaults to False |
outline | bool | False | highlight elements if True, defaults to False |
param screenshot: | |
---|---|
save element screenshot if True, defaults to False | |
param element_json: | |
save element json if True, defaults to False | |
param outline: | highlight elements if True, defaults to False |
return: | all controls and all elements |
Examples
Get list of open windows
Window dictionaries contain:
- automation_id
- control_id
- title
- pid
- handle
- is_active
- keyboard_focus
- rectangle
return: | list of window dictionaries |
---|
Examples
Is element matching. Check if locator is found in any field or criteria field in the window items.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
itemdict | dict | null | |
locator | str | null | name of the locator |
criteria | str | null | criteria on which to match element |
wildcard | bool | False | whether to do reg exp match or not, default False |
param itemDict: | dictionary of element items |
---|---|
param locator: | name of the locator |
param criteria: | criteria on which to match element |
param wildcard: | whether to do reg exp match or not, default False |
return: | True if element is matching locator and criteria, False if not |
Log into Windows domain with username and password.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
username | str | null | name of the user |
password | str | null | password of the user |
domain | str | . | windows domain for the user, defaults to "." |
param username: | name of the user |
---|---|
param password: | password of the user |
param domain: | windows domain for the user, defaults to "." |
return: | handle |
Examples
Minimize window by its title
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
windowtitle | str, None | None | name of the window, default None means that active window is going to be minimized |
param windowtitle: | |
---|---|
name of the window, default None means that active window is going to be minimized |
Examples
Mouse click locator, coordinates, or image
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
locator | str, None | None | element locator on active window |
x | int | 0 | coordinate x on desktop |
y | int | 0 | coordinate y on desktop |
off_x | int | 0 | offset x (used for locator and image clicks) |
off_y | int | 0 | offset y (used for locator and image clicks) |
image | str, None | None | image to click on desktop |
method | str | locator | one of the available methods to mouse click, default "locator" |
ctype | str | click | type of mouse click |
focus | str | center | default point for element click is 'center', can be set to 'topleft' to click top left corner of the element |
tolerance | int, None | None | image matching tolerance between 0 and 1 |
When using method locator,image or ocr mouse is clicked by default at center coordinates.
Click types are:
- click normal left button mouse click
- double
- right
param locator: | element locator on active window |
---|---|
param x: | coordinate x on desktop |
param y: | coordinate y on desktop |
param off_x: | offset x (used for locator and image clicks) |
param off_y: | offset y (used for locator and image clicks) |
param image: | image to click on desktop |
param method: | one of the available methods to mouse click, default "locator" |
param ctype: | type of mouse click |
param focus: | default point for element click is 'center', can be set to 'topleft' to click top left corner of the element |
param tolerance: | |
image matching tolerance between 0 and 1 |
Examples
Click at coordinates on desktop
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
x | int | null | horizontal coordinate on the windows to click |
y | int | null | vertical coordinate on the windows to click |
ctype | str | click | click type "click", "right" or "double", defaults to "click" |
delay_time | float, None | None |
param x: | horizontal coordinate on the windows to click |
---|---|
param y: | vertical coordinate on the windows to click |
param ctype: | click type "click", "right" or "double", defaults to "click" |
param delay: | delay in seconds after, default is no delay |
Examples
Click at template image on desktop
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
template | str | null | |
off_x | int | 0 | horizontal offset from top left corner to click on |
off_y | int | 0 | vertical offset from top left corner to click on |
ctype | str | click | type of mouse click |
tolerance | float, None | None | matching tolerance between 0 and 1 |
param image: | image to click on desktop |
---|---|
param off_x: | horizontal offset from top left corner to click on |
param off_y: | vertical offset from top left corner to click on |
param ctype: | type of mouse click |
param tolerance: | |
matching tolerance between 0 and 1 |
Examples
Open application by dispatch method
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
application | str | null | name of the application as str |
This keyword is used to launch Microsoft applications like Excel, Word, Outlook and Powerpoint.
param application: | |
---|---|
name of the application as str | |
return: | application instance id |
Examples
Open window by its title.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
windowtitle | str, None | None | name of the window, defaults to active window if None |
highlight | bool | False | draw outline for window if True, default False |
timeout | int | 10 | time to wait for dialog to appear |
existing_app | bool | False | set True if selecting window which library has already accessed, default False |
wildcard | bool | False | set True for inclusive window title search, default False |
parse_elements | bool | True | set False to not to parse elements of the window, default True |
param windowtitle: | |
---|---|
name of the window, defaults to active window if None | |
param highlight: | |
draw outline for window if True, default False | |
param timeout: | time to wait for dialog to appear |
param existing_app: | |
set True if selecting window which library has already accessed, default False | |
param wildcard: | set True for inclusive window title search, default False |
param parse_elements: | |
set False to not to parse elements of the window, default True |
Examples
Open Windows executable. Window title name is required to get handle on the application.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
executable | str | null | name of the executable |
windowtitle | str | null | name of the window |
backend | str, None | None | set Windows backend, default None means using library default value |
work_dir | str, None | None | path to working directory, default None |
wildcard | bool | False | set True for inclusive window title search, default False |
param executable: | |
---|---|
name of the executable | |
param windowtitle: | |
name of the window | |
param backend: | set Windows backend, default None means using library default value |
param work_dir: | path to working directory, default None |
param wildcard: | set True for inclusive window title search, default False |
return: | application instance id |
Examples
Open associated application when opening file
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
filename | str | null | path to file |
windowtitle | str, None | None | name of the window |
wildcard | bool | False | set True for inclusive window title search, default False |
timeout | int | 10 | time to wait for dialog to appear |
Keyword Open Dialog is used if windowtitle is given.
param filename: | path to file |
---|---|
param windowtitle: | |
name of the window | |
param wildcard: | set True for inclusive window title search, default False |
param timeout: | time to wait for dialog to appear |
return: | application id or None |
Examples
Open application using Windows search dialog. Window title name is required to get handle on the application.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
executable | str | null | name of the executable |
windowtitle | str | null | name of the window |
timeout | int | 10 | time to wait for dialog to appear |
wildcard | bool | False | set True for inclusive window title search, default False |
param executable: | |
---|---|
name of the executable | |
param windowtitle: | |
name of the window | |
param timeout: | time to wait for dialog to appear |
param wildcard: | set True for inclusive window title search, default False |
return: | application instance id |
Examples
Open application using Windows run dialog. Window title name is required to get handle on the application.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
executable | str | null | name of the executable |
windowtitle | str | null | name of the window |
timeout | int | 10 | time to wait for dialog to appear |
wildcard | bool | False | set True for inclusive window title search, default False |
param executable: | |
---|---|
name of the executable | |
param windowtitle: | |
name of the window | |
param timeout: | time to wait for dialog to appear |
param wildcard: | set True for inclusive window title search, default False |
return: | application instance id |
Examples
Check if process exists by its name
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
process_name | str | null | search for this process |
strict | bool | True | defines how match is made, default True which means that process name needs to be exact match and False does inclusive matching |
param process_name: | |
---|---|
search for this process | |
param strict: | defines how match is made, default True which means that process name needs to be exact match and False does inclusive matching |
return: | process instance or False |
Examples
Quit an application by application id or active application if app_id is None.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
app_id | int, None | None | application_id, defaults to None |
send_keys | bool | False | if ALT+F4 should be used to quit, default False |
param app_id: | application_id, defaults to None |
---|---|
param send_keys: | |
if ALT+F4 should be used to quit, default False |
Examples
Get controls and elements for current windows.
Should be called always when window content changes on Windows desktop.
return: | controls (list) and elements (list) |
---|
Restore window by its title
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
windowtitle | str, None | None | name of the window, default None means that active window is going to be restored |
param windowtitle: | |
---|---|
name of the window, default None means that active window is going to be restored |
Examples
Save screenshot into filename.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
filename | str | null | name of the file |
element | dict, None | None | take element screenshot, defaults to None |
ctrl | Any, None | None | take control screenshot, defaults to None |
desktop | bool | False | take desktop screenshot if True, defaults to False |
overwrite | bool | True | overwrite existing image (deprecated, always True) |
param filename: | name of the file |
---|---|
param element: | take element screenshot, defaults to None |
param ctrl: | take control screenshot, defaults to None |
param desktop: | take desktop screenshot if True, defaults to False |
param overwrite: | |
overwrite existing image (deprecated, always True) |
Examples
Send keys to windows and add ENTER if with_enter is True
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
keys_to_type | str | null | keys to type into Windows |
with_enter | bool | True | send ENTER if with_enter is True |
send_delay | float | 0.5 | delay after send_keys |
enter_delay | float | 1.5 | delay after ENTER |
At the end of send_keys there is by default 0.5 second delay. At the end of ENTER there is by default 1.5 second delay.
param keys_to_type: | |
---|---|
keys to type into Windows | |
param with_enter: | |
send ENTER if with_enter is True | |
param send_delay: | |
delay after send_keys | |
param enter_delay: | |
delay after ENTER |
Examples
Set global automation timings
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
speed | Speed | DEFAULT | possible values 'default', 'fast' or 'slow' |
param speed: | possible values 'default', 'fast' or 'slow' |
---|
Set Windows backend which is used to interact with Windows applications
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
backend | str | null | name of the backend to use |
Allowed values defined by SUPPORTED_BACKENDS
param backend: | name of the backend to use |
---|
Examples
Type keys into element matched by given locator.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
locator | str | null | element locator |
keys | str | null | list of keys to type |
empty_field | bool | False | if field should be emptied before typing, default False |
param locator: | element locator |
---|---|
param keys: | list of keys to type |
param empty_field: | |
if field should be emptied before typing, default False |
Examples
Wait for element to appear into the window.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
locator | str | null | name of the locator |
use_refreshing | bool | False | wait for element(s) which are not there yet e.g. listbox item or popups, default False |
search_criteria | str, None | None | criteria by which element is matched |
timeout | float | 30.0 | defines how long to wait for element to appear, defaults to 30.0 seconds |
interval | float | 2.0 | how often to poll for element, defaults to 2.0 seconds (minimum is 0.5 seconds) |
Can return 1 or more elements matching locator, or raises ElementNotFoundError if element is not found within timeout.
param locator: | name of the locator |
---|---|
param use_refreshing: | |
wait for element(s) which are not there yet e.g. listbox item or popups, default False | |
param search_criteria: | |
criteria by which element is matched | |
param timeout: | defines how long to wait for element to appear, defaults to 30.0 seconds |
param interval: | how often to poll for element, defaults to 2.0 seconds (minimum is 0.5 seconds) |