This class represents a visual GUI element in an application. More...
Public Member Functions | |
def | send_mouse_click (self, action=default_mouse_action, position=None) |
This method simulates the mouse action specified in the action parameter. More... | |
def | send_text (self, text, action=default_text_action, kl=default_kl, focus_action=default_focus_action) |
This method simulates the pressing and releasing of a key sequence, over a visual GUI element, represented by a string in the "text" parameter. More... | |
def | send_key (self, text, type=default_key_action, focus_action=default_focus_action) |
This method simulates - over a visual GUI element - the pressing of a specified key combination. More... | |
def | bounding_rectangle (self) |
This method returns the absolute coordinates of this visual GUI element on the desktop in the order left, top, right, bottom. More... | |
def | size (self) |
This method returns the size of this visual GUI element in the order width, height. More... | |
This class represents a visual GUI element in an application.
An instance of this class can be created by one of the AppElement class methods, such as AppElement.find_first_visual, AppElement.find_all_visual.
def urpa.VisualElement.bounding_rectangle | ( | self | ) |
This method returns the absolute coordinates of this visual GUI element on the desktop in the order left, top, right, bottom.
def urpa.VisualElement.send_key | ( | self, | |
text, | |||
type = default_key_action , |
|||
focus_action = default_focus_action |
|||
) |
This method simulates - over a visual GUI element - the pressing of a specified key combination.
Prior to the simulation of the pressing of the specified key combination, the TP window tied to the visual GUI element is transferred to the foreground. The actual simulation of the pressing of the specified key combination is only tied to the TP window handle, i.e. if the GUI element does not gain or loses focus during the simulation, the simulation will not be executed correctly. While simulating the key press, first the string from the "text" parameter is divided into individual characters. The delimiter between characters is "+". A sequence is then created that represents key press ("down") and key release ("up") according to the characters in the "text" parameter. For example, the Ctrl+Shift+s combination is broken down into the sequence Ctrl(Down)+Shift(Down)+s(Down)+s(Up)+Shift(Up)+Ctrl(Up). A 100 ms delay is "processed" following the simulation of the press (Down) / release (Up) of each key. If a Hardware simulation mode is set in the "type" parameter, the simulation must take place in the foreground. If a simulation is running in the background, when the "type" parameter is set to Hardware it is automatically transferred to the foreground. When the "type" parameter is set to a Standard value, during a simulation individual characters are converted into virtual-key codes, and the simulation can also run in the background. This method is not suitable for direct text input.
text | String
|
type | String The way in which the keystrokes are to be simulated.
|
focus_action | String The way in which control activation is to be simulated. See set_default_focus_action for options. |
ValueError | the "text" or "type" parameters passed does not have a valid format. |
Examples
The example of opening Internet Explorer on the about:blank page, invoking the "Show documents downloaded" dialogue box by simulating the pressing of the Ctrl+J keyboard shortcut and closing this dialogue box by simulating the Alt+Z keyboard shortcut.
def urpa.VisualElement.send_mouse_click | ( | self, | |
action = default_mouse_action , |
|||
position = None |
|||
) |
This method simulates the mouse action specified in the action parameter.
The mouse action is performed over the center of this visual GUI element. By default, this method makes an HW left mouse click in the center of the visual GUI element. Delays in sending individual messages that simulate the mouse action are set to 50 ms.
action | String A parameter specifying the type of mouse action that will be simulated over the visual GUI element. For possible parameter values, see the urpa.set_default_mouse_action method. |
position | a tuple with 2 int-type elements (left, top). Specifies the mouse click position in the format left, top. The coordinates are relative to the upper left corner of the visual GUI element. |
Examples
The example of opening https://playground.ultimaterpa.com in Internet Explorer, finding an "authentication" visual GUI element called "Continue", waiting for 3 seconds, simulating a click on the "Continue" visual GUI element found, finding the "Success" authentication element.
def urpa.VisualElement.send_text | ( | self, | |
text, | |||
action = default_text_action , |
|||
kl = default_kl , |
|||
focus_action = default_focus_action |
|||
) |
This method simulates the pressing and releasing of a key sequence, over a visual GUI element, represented by a string in the "text" parameter.
Prior to the simulation of the key press and release, the TP window tied to the visual GUI element is transferred to the foreground. The actual key press/release simulation is only tied to the TP window handle, i.e. if the GUI element does not gain or loses focus during the simulation, the simulation will not be executed correctly. While processing the key simultation, first the string from the "text" parameter is divided into individual characters. A sequence is then created that represents key press ("down") and key release ("up") according to the characters in the "text" parameter. For example, the string "Lev" is broken down into the sequence Shift(Down)+l(Down)+l(Up)+Shift(Up)+e(Down)+e(Up)+v(Down)+v(Up). A 100 ms delay is "processed" following the simulation of the press (Down) / release (Up) of each key. If one of the "hw" simulation modes is set in the "type" parameter, the simulation must take place in the foreground. If a simulation is running in the background, when the "type" parameter is set to one of the "hw" values it is automatically transferred to the foreground. When the "type" parameter is set to one of the "standard" values, during a simulation individual characters are converted into virtual-key codes or alt-codes, and then the simulation can also run in the background. When the "type" parameter is set to "wm_char", the string from the "text" parameter splits directly into individual characters in the simulation.
text | String Text, the writing of which will be simulated over an application tied to a visual GUI element represented by an instance of this class. |
action | String The mode for the simulation of individual keystrokes, represented by a string in the "text" parameter.
|
kl | String Represents the keyboard layout that is automatically set for an application tied to a visual GUI element when simulating text input. |
focus_action | String The way in which control activation is to be simulated. See set_default_focus_action for options. |
ValueError | one of the parameters passed does not have a valid format. |
Examples
The example of opening Internet Explorer on the about:blank page, simulating the input of the text https://playground.ultimaterpa.com in the address bar, and going to this page by pressing the Enter key.
def urpa.VisualElement.size | ( | self | ) |
This method returns the size of this visual GUI element in the order width, height.