Element

更新时间:
复制 MD 格式

click

click(element, *, button='left', index=1, timeout=10)

Method description

Clicks the anchor position of a computer vision (CV) control.

Parameter description

element: the name of the control. The value must be a string.

button: the button of the mouse. The value must be a string.

Valid values:

  • left

  • right

index: the subscript of the control. If multiple controls exist, specify an index as the subscript for each control. The value must be an integer.

timeout: the timeout period of searching for the control. The value must be an integer.

Sample code -rpa4.ai.cv.element.click-

# Note:
# 1. Before you call this method, you must use the control capture feature to capture the CV control that you want to use.
# 2. When you call this method, make sure that the page on which the control resides is open.
# The following code shows a call example:
import rpa4.ai.cv as cv

cv.element.click('Send Message')
cv.element.click('Profile Picture')

double_click

double_click(element, *, index=1, timeout=10)

Method description

Double-clicks the anchor position of a CV control.

Parameter description

element: the name of the control. The value must be a string.

index: the subscript of the control. If multiple controls exist, specify an index as the subscript for each control. The value must be an integer.

timeout: the timeout period of searching for the control. The value must be an integer.

Sample code -rpa4.ai.cv.element.double_click-

# Note:
# 1. Before you call this method, you must use the control capture feature to capture the CV control that you want to use.
# 2. When you call this method, make sure that the page on which the control resides is open.
# The following code shows a call example:
import rpa4.ai.cv as cv

cv.element.double_click('Field')

input_text

input_text(element, value, *, clear=True, index=1, wait_mili_seconds=20, timeout=10)

Method description

Enters text in the anchor location of a CV control.

Parameter description

element: the name of the control. The value must be a string.

value: the text to be entered. The value must be a string.

clear: specifies whether to clear the field before you enter the text. The value must be a Boolean value.

index: the subscript of the control. If multiple controls exist, specify an index as the subscript for each control. The value must be an integer.

wait_mili_seconds: the interval at which two consecutive characters are entered. Unit: milliseconds. Default value: 20. Maximum value: 100. The value must be an integer.

timeout: the timeout period of searching for the control. The value must be an integer.

Sample code -rpa4.ai.cv.element.input_text-

# Note:
# 1. Before you call this method, you must use the control capture feature to capture the CV control that you want to use.
# 2. When you call this method, make sure that the page on which the control resides is open.
# The following code shows a call example:
import rpa4.ai.cv as cv

cv.element.input_text('Search Box', 'Helen')

pos

pos(element, *, index=1, timeout=10)

Method description

Obtains the coordinates of a CV control.

Parameter description

element: the name of the control. The value must be a string.

index: the subscript of the control. If multiple controls exist, specify an index as the subscript for each control. The value must be an integer.

timeout: the timeout period of searching for the control. The value must be an integer.

Return value description

  • A dictionary of coordinates is returned. The keys are the bounding coordinates x1, x2, x3, and x4 and the anchor coordinates anchor_x and anchor_y of the control.

  • Example: {'x1':100, 'x2':100, 'y1':500, 'y2':500, 'anchor_x':300, 'anchor_y':300}

Sample code -rpa4.ai.cv.element.input_text-

# Note:
# 1. Before you call this method, you must use the control capture feature to capture the CV control that you want to use.
# 2. When you call this method, make sure that the page on which the control resides is open.
# The following code shows a call example:
import rpa4.ai.cv as cv

pos = cv.element.pos('Close Window')
center_x = (pos['x1'] + pos['x2']) // 2
center_y = (pos['y1'] + pos['y2']) // 2
rpa.ui.win32.click(x=center_x, y=center_y)

mouse_move

mouse_move(element, *, index=1, timeout=10)

Method description

Moves the pointer over the anchor position of a CV control.

Parameter description

element: the name of the control. The value must be a string.

index: the subscript of the control. If multiple controls exist, specify an index as the subscript for each control. The value must be an integer.

timeout: the timeout period of searching for the control. The value must be an integer.

Sample code -rpa4.ai.cv.element.mouse_move-

# Note:
# 1. Before you call this method, you must use the control capture feature to capture the CV control that you want to use.
# 2. When you call this method, make sure that the page on which the control resides is open.
# The following code shows a call example:
import rpa4.ai.cv as cv

cv.element.mouse_move('Profile Picture')
rpa.ui.win32.click()

wait_loaded

wait_loaded(element, *, index=1, timeout=10)

Method description

Waits for a CV control to be loaded. The operation ends if the CV control is loaded. An exception is thrown if the CV control fails to be loaded.

Parameter description

element: the name of the control. The value must be a string.

index: the subscript of the control. If multiple controls exist, specify an index as the subscript for each control. The value must be an integer.

timeout: the timeout period of searching for the control. The value must be an integer.

Sample code -rpa4.ai.cv.element.wait_loaded-

# Note:
# 1. Before you call this method, you must use the control capture feature to capture the CV control that you want to use.
# 2. When you call this method, make sure that the page on which the control resides is open.
# The following code shows a call example:
import rpa4.ai.cv as cv
try:
    cv.element.wait_loaded('Page Title')
except Exception as e:
    print(e)

count

count(element)

Method description

Queries the number of CV controls.

Parameter description

element: the name of the control. The value must be a string.

Return value description

The number of CV controls is returned. The value is an integer.

Sample code -rpa4.ai.cv.element.count-

# Note:
# 1. Before you call this method, you must use the control capture feature to capture the CV control that you want to use.
# 2. When you call this method, make sure that the page on which the control resides is open.
# The following code shows a call example:
import rpa4.ai.cv as cv

num = cv.element.count('Check Box')
print(num)