|
|
.. _module.robot.uidesktop:
|
|
|
|
|
|
####################################
|
|
|
2. UIDesktop
|
|
|
####################################
|
|
|
|
|
|
|
|
|
************************
|
|
|
Общее
|
|
|
************************
|
|
|
|
|
|
Here you can find the functions description for interaction with desktop GUI applications
|
|
|
|
|
|
|
|
|
************************
|
|
|
UIO объект
|
|
|
************************
|
|
|
|
|
|
************************
|
|
|
UIO селектор
|
|
|
************************
|
|
|
|
|
|
|
|
|
************************************************
|
|
|
UIO свойства и методы (общие)
|
|
|
************************************************
|
|
|
|
|
|
- process_id()
|
|
|
Return the ID of process that owns this window
|
|
|
|
|
|
- window_text()
|
|
|
Window text of the element
|
|
|
Quite a few contorls have other text that is visible, for example Edit controls usually have an empty string for window_text but still have text displayed in the edit window.
|
|
|
|
|
|
- windowclasses= []
|
|
|
|
|
|
- writable_props
|
|
|
Build the list of the default properties to be written.
|
|
|
|
|
|
Derived classes may override or extend this list depending on how much control they need.
|
|
|
- rectangle()
|
|
|
Return the rectangle of element: {"top", "left", "right", "bottom"}
|
|
|
The rectangle() is the rectangle of the element on the screen. Coordinates are given from the top left of the screen.
|
|
|
This method returns a RECT structure, Which has attributes - top, left, right, bottom. and has methods width() and height(). See win32structures.RECT for more information.
|
|
|
|
|
|
- right_click_input(coords=(None, None))
|
|
|
Right click at the specified coords
|
|
|
|
|
|
- click_input(button='left', coords=(None, None), button_down=True, button_up=True, double=False, wheel_dist=0, use_log=True, pressed='', absolute=False, key_down=True, key_up=True)
|
|
|
Click at the specified coordinates
|
|
|
button The mouse button to click. One of ‘left’, ‘right’, ‘middle’ or ‘x’ (Default: ‘left’, ‘move’ is a special case)
|
|
|
coords The coordinates to click at.(Default: the center of the control)
|
|
|
double Whether to perform a double click or not (Default: False)
|
|
|
wheel_dist The distance to move the mouse wheel (default: 0)
|
|
|
NOTES:
|
|
|
This is different from click method in that it requires the control to be visible on the screen but performs a more realistic ‘click’ simulation.
|
|
|
This method is also vulnerable if the mouse is moved by the user as that could easily move the mouse off the control before the click_input has finished.
|
|
|
|
|
|
- double_click_input(button='left', coords=(None, None))
|
|
|
Double click at the specified coordinates
|
|
|
|
|
|
- press_mouse_input(button='left', coords=(None, None), pressed='', absolute=True, key_down=True, key_up=True)
|
|
|
Press a mouse button using SendInput
|
|
|
|
|
|
- press_mouse_input(button='left', coords=(None, None), pressed='', absolute=True, key_down=True, key_up=True)
|
|
|
Press a mouse button using SendInput
|
|
|
|
|
|
- drag_mouse_input(dst=(0, 0), src=None, button='left', pressed='', absolute=True)
|
|
|
Click on src, drag it and drop on dst
|
|
|
dst is a destination wrapper object or just coordinates.
|
|
|
src is a source wrapper object or coordinates. If src is None the self is used as a source object.
|
|
|
button is a mouse button to hold during the drag. It can be “left”, “right”, “middle” or “x”
|
|
|
pressed is a key on the keyboard to press during the drag.
|
|
|
absolute specifies whether to use absolute coordinates for the mouse pointer locations
|
|
|
|
|
|
- wheel_mouse_input(coords=(None, None), wheel_dist=1, pressed='')
|
|
|
Do mouse wheel
|
|
|
|
|
|
- draw_outline(colour='green', thickness=2, fill=<MagicMock name='mock.win32defines.BS_NULL' id='140124673757368'>, rect=None)
|
|
|
Draw an outline around the window.
|
|
|
colour can be either an integer or one of ‘red’, ‘green’, ‘blue’ (default ‘green’)
|
|
|
thickness thickness of rectangle (default 2)
|
|
|
fill how to fill in the rectangle (default BS_NULL)
|
|
|
rect the coordinates of the rectangle to draw (defaults to the rectangle of the control)
|
|
|
|
|
|
- element_info
|
|
|
Read-only property to get ElementInfo object
|
|
|
|
|
|
- from_point(x, y)
|
|
|
Get wrapper object for element at specified screen coordinates (x, y)
|
|
|
|
|
|
- get_properties()
|
|
|
Return the properties of the control as a dictionary.
|
|
|
|
|
|
- is_child(parent)
|
|
|
Return True if this element is a child of ‘parent’.
|
|
|
An element is a child of another element when it is a direct of the other element. An element is a direct descendant of a given element if the parent element is the the chain of parent elements for the child element.
|
|
|
|
|
|
- is_dialog()
|
|
|
Return True if the control is a top level window
|
|
|
|
|
|
- is_enabled()
|
|
|
Whether the element is enabled or not
|
|
|
Checks that both the top level parent (probably dialog) that owns this element and the element itself are both enabled.
|
|
|
If you want to wait for an element to become enabled (or wait for it to become disabled) use Application.wait('visible') or Application.wait_not('visible').
|
|
|
If you want to raise an exception immediately if an element is not enabled then you can use the BaseWrapper.verify_enabled(). BaseWrapper.VerifyReady() raises if the window is not both visible and enabled.
|
|
|
|
|
|
|
|
|
- is_visible()
|
|
|
Whether the element is visible or not
|
|
|
Checks that both the top level parent (probably dialog) that owns this element and the element itself are both visible.
|
|
|
If you want to wait for an element to become visible (or wait for it to become hidden) use Application.wait('visible') or Application.wait_not('visible').
|
|
|
If you want to raise an exception immediately if an element is not visible then you can use the BaseWrapper.verify_visible(). BaseWrapper.verify_actionable() raises if the element is not both visible and enabled.
|
|
|
|
|
|
- parent()
|
|
|
Return the parent of this element
|
|
|
Note that the parent of a control is not necesarily a dialog or other main window. A group box may be the parent of some radio buttons for example.
|
|
|
To get the main (or top level) window then use BaseWrapper.top_level_parent().
|
|
|
|
|
|
- root()
|
|
|
Return wrapper for root element (desktop)
|
|
|
|
|
|
- set_focus()
|
|
|
Set the focus to this element
|
|
|
|
|
|
- texts()
|
|
|
Return the text for each item of this control
|
|
|
It is a list of strings for the control. It is frequently overridden to extract all strings from a control with multiple items.
|
|
|
It is always a list with one or more strings:
|
|
|
The first element is the window text of the control
|
|
|
Subsequent elements contain the text of any items of the control (e.g. items in a listbox/combobox, tabs in a tabcontrol)
|
|
|
|
|
|
- type_keys(keys, pause=None, with_spaces=False, with_tabs=False, with_newlines=False, turn_off_numlock=True, set_foreground=True, vk_packet=True)
|
|
|
Type keys to the element using keyboard.send_keys
|
|
|
Ограниченная функциональность. Для более полной функциональности рекомендуем ознакомится с pyOpenPRA.Robot.Keyboard
|
|
|
This uses the re-written keyboard python module where you can find documentation on what to use for the keys.
|
|
|
|
|
|
- was_maximized()
|
|
|
Indicate whether the window was maximized before minimizing or not
|
|
|
|
|
|
*************************************************************
|
|
|
UIO свойства и методы (дополнение для win32 элементов)
|
|
|
*************************************************************
|
|
|
Кнопка (Button || CheckBox || RadioButton || GroupBox)
|
|
|
|
|
|
- check()
|
|
|
Check a checkbox
|
|
|
|
|
|
- get_check_state()
|
|
|
Return the check state of the checkbox
|
|
|
The check state is represented by an integer 0 - unchecked 1 - checked 2 - indeterminate
|
|
|
The following constants are defined in the win32defines module BST_UNCHECKED = 0 BST_CHECKED = 1 BST_INDETERMINATE = 2
|
|
|
|
|
|
- click(button='left', pressed='', coords=(0, 0), double=False, absolute=False)
|
|
|
Click the Button control
|
|
|
- is_checked()
|
|
|
Return True if checked, False if not checked, None if indeterminate
|
|
|
- is_dialog()
|
|
|
Buttons are never dialogs so return False
|
|
|
- set_check_indeterminate()
|
|
|
Set the checkbox to indeterminate
|
|
|
- uncheck()
|
|
|
Uncheck a checkbox
|
|
|
- friendly_class_name()
|
|
|
Return the friendly class name of the button
|
|
|
|
|
|
Windows controls with the class “Button” can look like different controls based on their style. They can look like the following controls:
|
|
|
|
|
|
Buttons, this method returns “Button”
|
|
|
CheckBoxes, this method returns “CheckBox”
|
|
|
RadioButtons, this method returns “RadioButton”
|
|
|
GroupBoxes, this method returns “GroupBox”
|
|
|
|
|
|
|
|
|
Поле выбора нескольких значений из списка (ComboBox)
|
|
|
|
|
|
- dropped_rect()
|
|
|
Get the dropped rectangle of the combobox
|
|
|
- friendlyclassname= 'ComboBox'
|
|
|
- get_properties()
|
|
|
Return the properties of the control as a dictionary
|
|
|
item_count()
|
|
|
Return the number of items in the combobox
|
|
|
- item_data(item)
|
|
|
Returns the item data associated with the item if any
|
|
|
- item_texts()
|
|
|
Return the text of the items of the combobox
|
|
|
- select(item)
|
|
|
Select the ComboBox item
|
|
|
item can be either a 0 based index of the item to select or it can be the string that you want to select
|
|
|
- selected_index()
|
|
|
Return the selected index
|
|
|
- selected_text()
|
|
|
Return the selected text
|
|
|
- texts()
|
|
|
Return the text of the items in the combobox
|
|
|
- windowclasses= ['ComboBox', 'WindowsForms\\d*\\.COMBOBOX\\..*', '.*ComboBox']
|
|
|
|
|
|
Поле ввода (Edit)
|
|
|
|
|
|
- friendlyclassname= 'Edit'
|
|
|
- get_line(line_index)
|
|
|
Return the line specified
|
|
|
- line_count()
|
|
|
Return how many lines there are in the Edit
|
|
|
- line_length(line_index)
|
|
|
Return how many characters there are in the line
|
|
|
- select(start=0, end=None)
|
|
|
Set the edit selection of the edit control
|
|
|
- selection_indices()
|
|
|
The start and end indices of the current selection
|
|
|
- set_edit_text(text, pos_start=None, pos_end=None)
|
|
|
Set the text of the edit control
|
|
|
- set_text(text, pos_start=None, pos_end=None)
|
|
|
Set the text of the edit control
|
|
|
- set_window_text(text, append=False)
|
|
|
Override set_window_text for edit controls because it should not be used for Edit controls.
|
|
|
Edit Controls should either use set_edit_text() or type_keys() to modify the contents of the edit control.
|
|
|
- text_block()
|
|
|
Get the text of the edit control
|
|
|
- texts()
|
|
|
Get the text of the edit control
|
|
|
- windowclasses= ['Edit', '.*Edit', 'TMemo', 'WindowsForms\\d*\\.EDIT\\..*', 'ThunderTextBox', 'ThunderRT6TextBox']
|
|
|
|
|
|
|
|
|
Поле выбора 1-го значения из списка (ListBox)
|
|
|
|
|
|
- friendlyclassname= 'ListBox'
|
|
|
- get_item_focus()
|
|
|
Return the index of current selection in a ListBox
|
|
|
- is_single_selection()
|
|
|
Check whether the listbox has single selection mode.
|
|
|
- item_count()
|
|
|
Return the number of items in the ListBox
|
|
|
- item_data(i)
|
|
|
Return the item_data if any associted with the item
|
|
|
- item_rect(item)
|
|
|
Return the rect of the item
|
|
|
- item_texts()
|
|
|
Return the text of the items of the listbox
|
|
|
- select(item, select=True)
|
|
|
Select the ListBox item
|
|
|
item can be either a 0 based index of the item to select or it can be the string that you want to select
|
|
|
- selected_indices()
|
|
|
The currently selected indices of the listbox
|
|
|
- set_item_focus(item)
|
|
|
Set the ListBox focus to the item at index
|
|
|
- texts()
|
|
|
Return the texts of the control
|
|
|
- windowclasses= ['ListBox', 'WindowsForms\\d*\\.LISTBOX\\..*', '.*ListBox']
|
|
|
|
|
|
Выпадающее меню (PopupMenu)
|
|
|
|
|
|
- friendlyclassname= 'PopupMenu'
|
|
|
- is_dialog()
|
|
|
Return whether it is a dialog
|
|
|
- windowclasses= ['#32768']
|
|
|
|
|
|
Текст (Static)
|
|
|
|
|
|
- friendlyclassname= 'Static'
|
|
|
- windowclasses= ['Static', 'WindowsForms\\d*\\.STATIC\\..*', 'TPanel', '.*StaticText']
|
|
|
|
|
|
*************************************************************
|
|
|
UIO свойства и методы (дополнение для uia элементов)
|
|
|
*************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
************************************************
|
|
|
Инициализация 2-х разрядностей для UIO
|
|
|
************************************************
|
|
|
|
|
|
pyOpenRPA позволяет обеспечить максимальную совместимость со всеми приложениями, которые выполняются на компьютере. Мы рекомендуем разрабатывать робота под интерпретатором Python x64. В дополнение к нему Вы можете подключить Python x32 (см. ниже пример подключения). Если планируемый робот не будет взаимодействовать через pyOpenRPA.Robot.UIDesktop с другой разрядность, то эту настройку можно не применять.
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
from pyOpenRPA.Robot import UIDesktop
|
|
|
# В нашем случае процесс робота будет исполняться на Python x64. Дополнительно подключим Python x32 (делать это только, если вы планируете работать в другой разрядностью в рамках робота)
|
|
|
lPyOpenRPA_SettingsDict = {
|
|
|
"Python32FullPath": "..\\Resources\\WPy32-3720\\python-3.7.2\\python.exe",# Путь к интерпретатору Python.exe x32
|
|
|
"Python64FullPath": "..\\Resources\\WPy64-3720\\python-3.7.2.amd64\\python.exe", # Путь к интерпретатору Python.exe x64
|
|
|
"Python32ProcessName": "pyOpenRPA_UIDesktopX32.exe", # Наименование процесса робота x32 в диспетчере задач. Установите свое наименование
|
|
|
"Python64ProcessName": "pyOpenRPA_UIDesktopX64.exe" # Наименование процесса робота x64 в диспетчере задач. Установите свое наименование
|
|
|
}
|
|
|
# Инициализировать 2-й разрядность.
|
|
|
UIDesktop.Utils.ProcessBitness.SettingsInit(lPyOpenRPA_SettingsDict)
|
|
|
# Теперь при вызове функций pyOpenRPA.Robot.UIDesktop платформа pyOpenRPA будет отслеживать разрядность приложения и отправлять соответсвующий вызов на идентичную разрядность.
|
|
|
|
|
|
|
|
|
.. automodule:: pyOpenRPA.Robot.UIDesktop
|
|
|
:members:
|
|
|
:autosummary:
|
|
|
|
|
|
|
|
|
**********
|
|
|
Ссылки
|
|
|
**********
|
|
|
|
|
|
`reStructuredText`_
|
|
|
|
|
|
.. target-notes::
|
|
|
.. _`reStructuredText`: http://docutils.sourceforge.net/rst.html
|