The urpa module can be used for process automation. More...
Classes | |
class | App |
A class representing a general application. More... | |
class | AppElement |
This class represents the GUI element in an application. More... | |
class | AppExcel |
A class representing MS Excel. More... | |
class | AppIE |
This class is used to manage the Internet Explorer browser window. More... | |
class | AppJavaElement |
class | Condition |
This class is used to define conditions for GUI element searches. More... | |
class | ConditionFactory |
This class is used to create an instance of a Condition-type object and to define the conditions for searching for GUI elements in this instance of the object. More... | |
class | Config |
class | ElementNotFoundError |
Exception raised when the required GUI element could not be found. More... | |
class | ExcelCells |
This method represents one cell, one row, a column or a block of cells in an MS Excel workbook sheet. More... | |
class | ExcelWorkbook |
This class represents a workbook in MS Excel. More... | |
class | ExcelWorksheet |
This class represents one sheet in an MS Excel workbook. More... | |
class | JavaCondition |
This class is used to define conditions for GUI element searches. More... | |
class | Transformation |
An auxiliary class that defines how images are to be transformed. More... | |
class | TransformationFactory |
An auxiliary class that defines how images are to be transformed. More... | |
class | VisualElement |
This class represents a visual GUI element in an application. More... | |
Functions | |
def | set_password (system, user, password) |
The "Windows Credential Vault", separate for each user profile, is used to store login details. More... | |
def | get_password (system, user) |
The "Windows Credential Vault", separate for each user profile, is used to store login details. More... | |
def | set_debug_mode (debug_mode, sleep_time=None) |
If enabled, it highlights the elements found and also waits for a certain time after an element has been found. More... | |
def | set_default_timeout (timeout) |
Defines the default timeout for all element searches. More... | |
def | set_default_text_action (type, char_delay=None, decomposition_delay=None) |
Defines the default text action type and, optionally, the inter-character delay while simulating the text typing. More... | |
def | set_default_mouse_action (type) |
This method defines the default mouse action type. More... | |
def | set_default_focus_action (type) |
Sets the default action type for invoking AppElement.set_focus. More... | |
def | set_default_key_action (type) |
Sets the default action type for send_key. More... | |
def | set_default_keyboard_layout (kl) |
Sets the default keyboard layout for word processing. More... | |
def | set_default_search_method (method) |
Sets the default search type for methods find_first, find_all. More... | |
def | condition_factory () |
Auxiliary class for entering more complex search conditions, see ConditionFactory. More... | |
def | transformation_factory () |
An auxiliary class that defines how images are to be transformed viz TransformationFactory. More... | |
def | exec_app (cmd_line, show_window=None) |
Runs a general application, see the App class. More... | |
def | exec_excel_app (filename=None) |
Runs Excel. More... | |
def | exec_ie_app (url=None) |
Runs Internet Explorer and goes to the URL passed. More... | |
def | open_app (pid) |
Opens the application with the process ID (PID) entered. More... | |
def | find_first_app (name, timeout=default_timeout) |
Finds the running application according to the name parameter passed. More... | |
def | find_first_excel_app (timeout=default_timeout) |
Finds the already running Excel application. More... | |
def | find_first_ie_app () |
Finds already running Internet Explorer application. More... | |
def | bring_to_foreground (foreground=True) |
Switches the simulation to the foreground/background. More... | |
def | default_error_processing () |
Executes default exception processing: i.e. More... | |
def | check_screen_resolution (width, height, bits_per_pixel=None) |
Executes a resolution and color depth check. More... | |
def | set_screen_resolution (width, height, bits_per_pixel=None) |
Sets resolution and color depth of default display device. More... | |
def | set_clipboard_text (text) |
Inserts the text passed into the Windows clipboard. More... | |
def | clipboard_text () |
Returns text stored in the Windows clipboard. More... | |
def | write_sydesk_measure (directory, source_id, value, expiration, description=None) |
It writes measurements in msr6 format to the directory passed. More... | |
def | write_measure (name, status, value=None, unit=None, tolerance=0, description=None, precision=None, id=None) |
It writes measurements to the directory passed. More... | |
def | take_screenshot () |
Variables | |
int | default_timeout = 5000 |
Default timeout for all searches, see set_default_timeout. More... | |
string | default_kl = "00000409" |
string | default_text_action = "WM_CHAR" |
int | default_char_delay = 50 |
int | default_decomposition_delay = 20 |
string | default_key_action = "Hardware" |
string | default_mouse_action = "HW Left" |
string | default_focus_action = "Default" |
default = Config() | |
The urpa module can be used for process automation.
Calling from multiple threads is not supported.
The print function prints information to the log and the standard output.
def urpa.bring_to_foreground | ( | foreground = True | ) |
Switches the simulation to the foreground/background.
foreground | bool True to switch simulation to the foreground or switch to the simulation desktop. False to switch simulation back to the background. |
def urpa.check_screen_resolution | ( | width, | |
height, | |||
bits_per_pixel = None |
|||
) |
Executes a resolution and color depth check.
width | int |
height | int |
bits_per_pixel | int |
ValueError | if the resolution/color depth does not match |
def urpa.clipboard_text | ( | ) |
Returns text stored in the Windows clipboard.
def urpa.condition_factory | ( | ) |
Auxiliary class for entering more complex search conditions, see ConditionFactory.
def urpa.default_error_processing | ( | ) |
Executes default exception processing: i.e.
executes a screenshot and an error log in relation to the last exception raised.
def urpa.exec_app | ( | cmd_line, | |
show_window = None |
|||
) |
def urpa.exec_excel_app | ( | filename = None | ) |
Runs Excel.
The path to the binary is detected automatically.
filename | String Optional argument to specify which Excel file to open. |
def urpa.exec_ie_app | ( | url = None | ) |
Runs Internet Explorer and goes to the URL passed.
The path to the binary is detected automatically.
url | String Optional argument to specify which URL to navigate to. |
def urpa.find_first_app | ( | name, | |
timeout = default_timeout |
|||
) |
Finds the running application according to the name parameter passed.
Finding already running applications makes it possible to work with applications that are not run via urpa.exec_*.
Raises the urpa.ElementNotFoundError exception if the application could not be found within the timeout period.
name | String The exact title name of the TP window or the ClassName of the TP window tied to an instance of the class returned. |
timeout | int [ms] The maximum time in which a TP window meeting the name condition must be retrieved. If this parameter is not entered, the default value is used, see urpa.default_timeout. |
ElementNotFoundError | the application required could not be found within the timeout period. |
Examples
Open the notepad application. Then after some time, search for application with "pad" in the name.".
def urpa.find_first_excel_app | ( | timeout = default_timeout | ) |
Finds the already running Excel application.
Finding an already running Excel application makes it possible to work with Excel that is not run via urpa.exec_excel_app.
Raises the urpa.ElementNotFoundError exception if the application could not be found within the timeout period.
timeout | int [ms] Maximum time to find Excel application. If this parameter is not passed, the default value is applied, see urpa.default_timeout. |
ElementNotFoundError | the application required could not be found within the timeout period. |
def urpa.find_first_ie_app | ( | ) |
Finds already running Internet Explorer application.
def urpa.get_password | ( | system, | |
user | |||
) |
The "Windows Credential Vault", separate for each user profile, is used to store login details.
Records can be user-managed with Credential Manager, a standard tool where the general credential name, the username and then the password are entered.
def urpa.open_app | ( | pid | ) |
Opens the application with the process ID (PID) entered.
Raises an exception if the process with the ID passed does not exist or cannot be opened.
pid | int The application process ID. |
def urpa.set_clipboard_text | ( | text | ) |
Inserts the text passed into the Windows clipboard.
def urpa.set_debug_mode | ( | debug_mode, | |
sleep_time = None |
|||
) |
If enabled, it highlights the elements found and also waits for a certain time after an element has been found.
debug_mode | Boolean True to enable debug mode, False otherwise |
sleep_time | int [ms] Time in ms to wait after an element has been found and highlighted. |
def urpa.set_default_focus_action | ( | type | ) |
Sets the default action type for invoking AppElement.set_focus.
The setting also affects the send_text and send_key methods, where the set_focus method is invoked automatically before simulating key presses.
type | String
|
def urpa.set_default_key_action | ( | type | ) |
Sets the default action type for send_key.
type | String The way in which the keystrokes are to be simulated.
|
def urpa.set_default_keyboard_layout | ( | kl | ) |
Sets the default keyboard layout for word processing.
It only affects writing with *_Scan_Virtual types.
kl | String Keyboard layout
|
def urpa.set_default_mouse_action | ( | type | ) |
This method defines the default mouse action type.
type | String
|
def urpa.set_default_search_method | ( | method | ) |
Sets the default search type for methods find_first, find_all.
method | String
|
def urpa.set_default_text_action | ( | type, | |
char_delay = None , |
|||
decomposition_delay = None |
|||
) |
Defines the default text action type and, optionally, the inter-character delay while simulating the text typing.
See send_text function notes for more details.
For *_Scan_Virtual types, the keyboard layout must be configured correctly, see set_default_keyboard_layout. For *_Alt_code types, HKEY_CURRENT_USER\Control Panel\Input Method needs to have EnableHexNumpad enabled in the registers.
type | String The mode for the simulation of individual keystrokes, represented by a string in the "text" parameter in the send_text function.
|
char_delay | int [ms] Inter-character delay in ms. |
decomposition_delay | int [ms] Character delay in ms. |
def urpa.set_default_timeout | ( | timeout | ) |
Defines the default timeout for all element searches.
timeout | int [ms] |
def urpa.set_password | ( | system, | |
user, | |||
password | |||
) |
The "Windows Credential Vault", separate for each user profile, is used to store login details.
Records can be user-managed with Credential Manager, a standard tool where the general credential name, the username and then the password are entered.
def urpa.set_screen_resolution | ( | width, | |
height, | |||
bits_per_pixel = None |
|||
) |
Sets resolution and color depth of default display device.
width | int |
height | int |
bits_per_pixel | int |
def urpa.take_screenshot | ( | ) |
def urpa.transformation_factory | ( | ) |
An auxiliary class that defines how images are to be transformed viz TransformationFactory.
def urpa.write_measure | ( | name, | |
status, | |||
value = None , |
|||
unit = None , |
|||
tolerance = 0 , |
|||
description = None , |
|||
precision = None , |
|||
id = None |
|||
) |
It writes measurements to the directory passed.
The start of the measurement is the current time.
name | String |
status | String (SUCCESS|WARNING|ERROR|INFO|NONE) |
value | float Measure value. |
unit | String Measurement value unit, e.g. %. |
tolerance | float |
description | String Optional measurement caption. |
precision | int |
id | String Optional measurement ID. If none is entered, this is taken to be the argument name ID. |
def urpa.write_sydesk_measure | ( | directory, | |
source_id, | |||
value, | |||
expiration, | |||
description = None |
|||
) |
It writes measurements in msr6 format to the directory passed.
The start of the measurement is the current time.
directory | String The directory to which the data record is to be written. |
source_id | String Data source ID in SyDesk. |
value | float or None Measure value. None means monitor failure. |
expiration | int Measurement validity in seconds. |
description | String Optional measurement caption. |
urpa.default = Config() |
int urpa.default_char_delay = 50 |
int urpa.default_decomposition_delay = 20 |
string urpa.default_focus_action = "Default" |
string urpa.default_key_action = "Hardware" |
string urpa.default_kl = "00000409" |
string urpa.default_mouse_action = "HW Left" |
string urpa.default_text_action = "WM_CHAR" |
int urpa.default_timeout = 5000 |
Default timeout for all searches, see set_default_timeout.