This is UltimateRPA Documentation
urpa Namespace Reference

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()
 

Detailed Description

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.

Function Documentation

◆ bring_to_foreground()

def urpa.bring_to_foreground (   foreground = True)

Switches the simulation to the foreground/background.

Parameters
foregroundbool True to switch simulation to the foreground or switch to the simulation desktop. False to switch simulation back to the background.

◆ check_screen_resolution()

def urpa.check_screen_resolution (   width,
  height,
  bits_per_pixel = None 
)

Executes a resolution and color depth check.

Parameters
widthint
heightint
bits_per_pixelint
Exceptions
ValueErrorif the resolution/color depth does not match

◆ clipboard_text()

def urpa.clipboard_text ( )

Returns text stored in the Windows clipboard.

◆ condition_factory()

def urpa.condition_factory ( )

Auxiliary class for entering more complex search conditions, see ConditionFactory.

Returns
ConditionFactory

◆ default_error_processing()

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.

◆ exec_app()

def urpa.exec_app (   cmd_line,
  show_window = None 
)

Runs a general application, see the App class.

Parameters
cmd_lineString
show_windowString
  • Minimize
  • Maximize
  • Normal
  • Hide
Returns
App

◆ exec_excel_app()

def urpa.exec_excel_app (   filename = None)

Runs Excel.

The path to the binary is detected automatically.

Parameters
filenameString Optional argument to specify which Excel file to open.
Returns
AppExcel

◆ exec_ie_app()

def urpa.exec_ie_app (   url = None)

Runs Internet Explorer and goes to the URL passed.

The path to the binary is detected automatically.

Parameters
urlString Optional argument to specify which URL to navigate to.
Returns
AppIE

◆ find_first_app()

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.

Parameters
nameString The exact title name of the TP window or the ClassName of the TP window tied to an instance of the class returned.
timeoutint [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.
Returns
App
Exceptions
ElementNotFoundErrorthe 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.".

app = urpa.exec_app("notepad.exe")
.
.
urpa.find_first_app(cf.regexp("pad"))

◆ find_first_excel_app()

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.

Parameters
timeoutint [ms] Maximum time to find Excel application. If this parameter is not passed, the default value is applied, see urpa.default_timeout.
Returns
AppExcel
Exceptions
ElementNotFoundErrorthe application required could not be found within the timeout period.

◆ find_first_ie_app()

def urpa.find_first_ie_app ( )

Finds already running Internet Explorer application.

Returns
AppIE

◆ get_password()

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.

◆ open_app()

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.

Parameters
pidint The application process ID.
Returns
App
ElementNotFoundError

◆ set_clipboard_text()

def urpa.set_clipboard_text (   text)

Inserts the text passed into the Windows clipboard.

◆ set_debug_mode()

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.

Parameters
debug_modeBoolean True to enable debug mode, False otherwise
sleep_timeint [ms] Time in ms to wait after an element has been found and highlighted.

◆ set_default_focus_action()

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.

Parameters
typeString
  • Default - when a hidden desktop is used, this method takes a "long" time (2s)
  • Mouse - the element is enabled with a mouse click
  • None - the element will not be enabled

◆ set_default_key_action()

def urpa.set_default_key_action (   type)

Sets the default action type for send_key.

Parameters
typeString The way in which the keystrokes are to be simulated.
  • Hardware
  • Standard

◆ set_default_keyboard_layout()

def urpa.set_default_keyboard_layout (   kl)

Sets the default keyboard layout for word processing.

It only affects writing with *_Scan_Virtual types.

Parameters
klString Keyboard layout
  • 00000405 - Czech (Czech, CSY, Czech Republic)
  • 00000409 - English (US, ENU, United States)
  • 0000041B - Slovak (Slovak, SKY, Slovakia)

◆ set_default_mouse_action()

def urpa.set_default_mouse_action (   type)

This method defines the default mouse action type.

Parameters
typeString
  • HW Left
  • HW Right
  • HW Middle
  • HW Move
  • HW Left Down
  • HW Right Down
  • HW Middle Down
  • HW Left Up
  • HW Right Up
  • HW Middle Up
  • Left
  • Right
  • Middle
  • Left Down
  • Right Down
  • Middle Down
  • Left Up
  • Right Up
  • Middle Up

◆ set_default_search_method()

def urpa.set_default_search_method (   method)

Sets the default search type for methods find_first, find_all.

Parameters
methodString
  • default
  • tree_walk

◆ set_default_text_action()

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.

Parameters
typeString The mode for the simulation of individual keystrokes, represented by a string in the "text" parameter in the send_text function.
  • HW_Alt_code
  • HW_Scan_Virtual
  • Standard_Alt_code
  • Standard_Scan_Virtual
  • WM_CHAR
char_delayint [ms] Inter-character delay in ms.
decomposition_delayint [ms] Character delay in ms.

◆ set_default_timeout()

def urpa.set_default_timeout (   timeout)

Defines the default timeout for all element searches.

Parameters
timeoutint [ms]

◆ set_password()

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.

◆ set_screen_resolution()

def urpa.set_screen_resolution (   width,
  height,
  bits_per_pixel = None 
)

Sets resolution and color depth of default display device.

Parameters
widthint
heightint
bits_per_pixelint

◆ take_screenshot()

def urpa.take_screenshot ( )

◆ transformation_factory()

def urpa.transformation_factory ( )

An auxiliary class that defines how images are to be transformed viz TransformationFactory.

Returns
TransformationFactory

◆ write_measure()

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.

Parameters
nameString
statusString (SUCCESS|WARNING|ERROR|INFO|NONE)
valuefloat Measure value.
unitString Measurement value unit, e.g. %.
tolerancefloat
descriptionString Optional measurement caption.
precisionint
idString Optional measurement ID. If none is entered, this is taken to be the argument name ID.

◆ write_sydesk_measure()

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.

Parameters
directoryString The directory to which the data record is to be written.
source_idString Data source ID in SyDesk.
valuefloat or None Measure value. None means monitor failure.
expirationint Measurement validity in seconds.
descriptionString Optional measurement caption.

Variable Documentation

◆ default

urpa.default = Config()

◆ default_char_delay

int urpa.default_char_delay = 50

◆ default_decomposition_delay

int urpa.default_decomposition_delay = 20

◆ default_focus_action

string urpa.default_focus_action = "Default"

◆ default_key_action

string urpa.default_key_action = "Hardware"

◆ default_kl

string urpa.default_kl = "00000409"

◆ default_mouse_action

string urpa.default_mouse_action = "HW Left"

◆ default_text_action

string urpa.default_text_action = "WM_CHAR"

◆ default_timeout

int urpa.default_timeout = 5000

Default timeout for all searches, see set_default_timeout.