История страницы
...
Get related elements Version 2 (Net)
Группа действий: Windows Подгруппа "Работа с win-элементами"
Описание
Действие проверяет указанный элемент и возвращает связанные с ним элементы (родительские/дочерние/соседние)
Пример на "Блокноте":
Для элемента "Масштаб" соседним элементом будет "Строка состояния". Родительский элемент - "Вид". Дочерние элементы: "Увеличить", "Уменьшить", "Восстановить масштаб по умолчанию".
Иконка действия
Параметры
Входные параметры
Элемент Параметр, который хранит данные Win-элемента, координаты которого будут проверяться
Тип связи Выпадающий список с элементами: "Родительские элементы", "Дочерние элементы", "Соседние элементы"
Если выбрана "Родительский элемент", то в результате вернется коллекция с win-элементами, которые являются родителями для указанного элемента
Если выбрана "Дочерние элементы", то в результате вернется коллекция с win-элементами, которые являются дочерними для указанного элемента
Если выбрано "Соседние элементы", то в результате вернется коллекция с win-элементами, которые являются "соседями" для указанного элемента, то есть имеют общего родителя
Глубина поиска Уровень вложенности связанных элементов, до которого будет производиться поиск. Положительное целое число от 1 до бесконечности
По умолчанию - "1". Глубина не учитывается, если в "Тип связи" выбрано значение "Соседние элементы"
Если глубина, указанная в параметре, больше фактической глубины в приложении, то берутся все элементы до фактической глубины
Тайм-аут Время в миллисекундах, в течение которого будет происходить поиск нужного элемента
Номер окна Порядковый номер окна, с которым будет взаимодействовать действие, если обнаружено несколько окон
При этом действие ищет только те окна, в которых должен находиться элемент согласно его параметрам
Положительное целое число от 1. По умолчанию - "1"
Выходные параметры
Результат Коллекция win-элементов
...
Action group: Windows Subgroup "Interaction with Win-elements"
...
Description
The action checks the specified element and returns elements related to it (parent/child/neighboring).
Example in Notepad:
"Status bar" is the neighboring element to "Scale". Parent element - "View". Daughter elements: "Zoom in", "Zoom out", "Set scale by default".
Action icon
Settings of parameters
Parameter | Description |
---|---|
Element | Parameter that stores the data of the Win-element whose coordinates will be checked. |
Type of connection | Drop-down list with elements: "Parent elements", "Daughter elements", "Neighboring elements". If "Parent element" is selected, the result will be a collection with Win-elements that are the parents of the specified element. If "Daughter elements" is selected, the result will be a collection with Win-elements that are daughters to the specified element. If "Neighboring elements" is selected, the result will be a collection with Win-elements that are "neighbors" for the specified element, I.e. they have a common parent. |
Search depth | Nesting level of related elements to which the search will be performed. A positive integer from 1 to infinity. Default value is "1". The depth is not taken into account if the value "Neighboring elements" is selected in the "Type of connection" field. If the depth specified in the parameter is greater than the actual depth in the application, then all elements up to the actual depth are taken. |
Time-out, ms | Time in milliseconds for which the desired element will be searched. |
Window order | Sequence number of the window that the action should work with if there are multiple windows. In this case, the action searches only for those windows in which the element should be located according to its parameters. A positive integer from 1. The default is "1". |
Output parameters
Result - a collection of Win-elements.
Settings
Property | Description | Type | Filling example | Mandatory field |
---|---|---|---|---|
Parameters | ||||
Element | A resource that stores data about the selected application element. | Robin.WinElement | Yes | |
Type of connection | The type of relationship between the elements being searched for and the specified element. You can search for elements that are parent, child, or neighbor to the specified element. Neighbors share a common parent element with the searched element. | Robin.String | Yes | |
Search depth | The nesting level of related elements to which the search will be performed. If the specified depth is greater than the actual depth, the action will return all elements up to the actual depth. The default value is 1. The parameter is ignored if the |
"Neighboring items" value is selected in the |
"Type of |
connection" field. | Robin.Numeric | No | ||
Time-out, ms | The time in milliseconds for which the desired element will be searched. | Robin.Numeric | No | |
Window order | The sequence number of the window that the action should work with. If you do not specify a window number, the first window will be checked. The numbering starts from 1. | Robin.Numeric | No | |
Results | ||||
---|---|---|---|---|
Result | A collection with related elements. | Robin.Collection |
Особые условия использования
Если пользователь в "Тип связи" выбирает "Родительские элементы" и у указанного win-элемента отсутствует родитель, то в результате вернется пустая коллекция.
Если пользователь в "Тип связи" выбирает "Соседние элементы" и у указанного win-элемента отсутствуют соседи, то в результате вернется пустая коллекция.
Если пользователь в "Тип связи" выбирает "Дочерние элементы" и у указанного win-элемента отсутствуют дети, то в результате вернется пустая коллекция.
Метод обхода графа - в ширину.
Пример работы действия
Special conditions of use
If the user selects "Parent elements" in the "Type of connection" field and the specified Win-element does not have a parent, an empty collection will be returned as a result.
If the user selects "Neighboring elements" in the "Type of connection" field and the specified Win-element does not have neighbors, an empty collection will be returned as a result.
If the user selects "Daughter elements" in the "Type of connection" field and the specified Win-element does not have daughters, an empty collection will be returned as a result.
The graph traversal method is in width.
Example of action performance
- The user specified element L, "Search depth"=3, "Type of connection" = "Parent elements". The result is a collection with elements E, B, A.
- The user specified element B, "Search depth"=2, "Type of connection" = "Daughter elements". The result is a collection with elements
- Пользователь указал элемент L, "Глубина поиска"=3, "Тип связи" = "Родительские элементы". Результат - коллекция с элементами E, B, A
- Пользователь указал элемент B, "Глубина поиска"=2, "Тип связи" = "Дочерние элементы". Результат - коллекция с элементами D, E, I, J, K, LПользователь указал элемент .
- The user specified element F, "Тип связиType of connection" = "Соседние элементы". Результат - коллекция с элементами Neighboring elements". The result is a collection with elements G,HПользователь указал элемент .
- The user specified element A, "Тип связиType of connection" = "Родительские элементы". Результат - пустая коллекция
- Пользователь указал элемент A, "Тип связи" = "Соседние элементы". Результат - пустая коллекция
- Пользователь указал элемент I, "Тип связи" = "Дочерние элементы". Результат - пустая коллекция
Пример использования
Задача
Открыто окно с названием "Блокнот". Необходимо получить соседние, дочерние и родительские элементы элемента "Масштаб".
Решение
Воспользоваться действием "Получить связанные элементы".
Реализация
- Собрать робота, состоящего из действий:
- Настроить параметры действия "Run":
- Настроить параметр действия "Window focus element". Элемент необходимо получить с помощью инструмента WinSpy. Работа с WinSpy описана в разделе Получение win-элемента. Установка тайм-аута, в целом, не приводит к увеличению времени выполнения действия сверх того времени, которое потребуется для того, чтобы элемент, который мы используем в действии стал видимым и доступным. В течение установленного тайм-аута действие пытается получить доступ к элементу с которым работает. Как только появляется доступ к элементу, ожидание тайм-аут заканчивается.
- Настроить параметр действия "Window focus element Scale". Элемент необходимо получить с помощью инструмента WinSpy. Работа с WinSpy описана в разделе Получение win-элемента.
- Настроить параметр действия "Get related elements". Выбираем ранее полученный с помощью инструмента WinSpy элемент "Масштаб1" и тип связи - Дочерние элементы:
- Настроить параметр действия "Get length". В поле Коллекция или массив, указываем результат действия "Получить связанные элементы":
- Настроить параметр действия "Subtraction". Второй операнд будет 1:
- Настроить параметр цикла "For". В поле Конечное значение, указываем результат действия "Subtraction":
- Настроить параметр действия "Get value by index". В поле Коллекция, указываем результат действия "Get related elements", в поле Индекс, указываем состояния итератора цикла "For":
- Настроить параметры действия "Terminate":
- Нажать на кнопку "Старт" в верхней панели.
Результат
Программный робот отработал успешно.
Дочерние элементы "Увеличить", "Уменьшить", "Восстановить масштаб по умолчанию" получены.
Пример 2
- Изменить параметр действия "Get related elements". Выбираем ранее полученный с помощью инструмента WinSpy элемент "Scale1" и тип связи - Родительские элементы.
- Нажать на кнопку "Старт" в верхней панели.
Результат
Программный робот отработал успешно.
Родительский элемент "Вид" получен.
Пример 3
- Изменить параметр действия "Получить связанные элементы". Выбираем ранее полученный с помощью инструмента WinSpy элемент "Scale1" и тип связи - Соседние элементы.
- Нажать на кнопку "Старт" в верхней панели.
Результат
Программный робот отработал успешно.
- Parent elements". The result is an empty collection.
- The user specified element A, "Type of connection" = "Neighboring elements". The result is an empty collection.
- The user specified element I, "Type of connection" = "Daughter elements". The result is an empty collection.
Example of use
Task
A Notepad is opened. Get related elements of the "Scale" element.
Solution
Use the "Get related elements" action.
Implementation
- Assemble a robot scheme with the actions:
- Set the "Run" action parameters.
- Set the "Window focus element" action parameter. The element must be obtained using the WinSpy tool. Working with WinSpy is described in the section Getting a Win-element. Setting a timeout, in general, does not lead to an increase in the execution time of the action beyond the time it will take for the element that we use in the action to become visible and accessible. During the set timeout, the action tries to access the element it is working with. As soon as the element is accessed, the waiting timeout ends.
- Set the "Window focus element Scale" action parameter. The element must be obtained using the WinSpy tool. Working with WinSpy is described in the Getting a Win-element section.
- Set the "Get related elements" action parameter. Select the "Scale1" element that was obtained earlier using the WinSpy tool and the "Daughter elements" type of connection.
- Set the "Get length" action parameter. In the Collection field specify the result of the "Get related elements" action.
- Set the "Subtraction" action parameter. Настроить параметр действия "Subtraction". The second operand will be 1.
- Set the "For" loop parameter. In the Result field specify the "Subtraction" action result.
- Set the "Get value by index" action parameter. In the Collection field, specify the result of the "Get related elements" action, in the Index field, specify the states of the iterator of the "For" loop:
- Set the "Terminate" action parameters.
- Click "Start" in the top panel.
Result
The program robot completed successfully.
Daughter elements "Zoom in", "Zoom out", "Set scale by default" were obtained.
Example 2
- Change the parameter of the "Get related elements" action. Select the "Scale1" element previously obtained using the WinSpy tool and the type of connection - Parent elements.
- Click "Start" in the top panel.
Result
The program robot completed successfully.
Parent element "View" was obtained.
Example 3
- Change the parameter of the "Get related elements" action. Select the "Scale1" element previously obtained using the WinSpy tool and the type of connection - Neighboring elements.
- Click "Start" in the top panel.
Result
The program robot completed successfully.
The neighboring element "Status bar" was obtainedСоседний элемент "Строка состояния" получен.