文档

Window

更新时间:

activate

activate()

方法描述

激活窗口

调用样例- rpa.ui.win32.Window.activate-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.activate()

maximize

maximize()

方法描述

最大化窗口

调用样例- rpa.ui.win32.Window.maximize-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.maximize()

minimize

minimize()

方法描述

最小化窗口

调用样例- rpa.ui.win32.Window.minimize-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.minimize()

hide

hide()

方法描述

隐藏窗口

调用样例- rpa.ui.win32.Window.hide-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.hide()

show

show()

方法描述

窗口显示

调用样例- rpa.ui.win32.Window.show-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.show()

wait_disappear

wait_disappear(timeout=30)

方法描述

等待窗口消失

参数说明

timeout<int>超时时间

调用样例- rpa.ui.win32.Window.wait_disappear-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.wait_disappear()

close

close()

方法描述

关闭窗口

调用样例- rpa.ui.win32.Window.close-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.close()

get_element_by_name

get_element_by_name(element, index=1, parent_element=None, timeout=10)

方法描述

根据控件名获取控件对象

参数说明

element<str>控件名

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

返回值说明

返回控件对象<Element>

调用样例- rpa.ui.win32.Window.get_element_by_name-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
ele = wnd.get_element_by_name("记事本输入框")

count

count(element, parent_element=None)

方法描述

获取控件个数

参数说明

element<str>控件名

parent_element<Element>父控件对象

返回值说明

返回控件个数<int>

调用样例- rpa.ui.win32.Window.count-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
ele_count = wnd.count("记事本输入框")

wait_loaded

wait_loaded(element, index=1, parent_element=None, timeout=10)

方法描述

等待加载控件,成功返回True,失败返回False

参数说明

element<str>控件名

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

返回值说明

返回是否加载成功<bool>

调用样例- rpa.ui.win32.Window.wait_loaded-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.wait_loaded("记事本输入框")

input_text

input_text(element, value, index=1, parent_element=None, simulate=False, replace=True, send_window_message=True, sent_raw=False, wait_mili_seconds=20, timeout=10)

方法描述

向控件中输入文本

参数说明

element<str>控件名

value<str>输入的内容

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

simulate<bool>是否模拟输入

replace<bool>是否清空之前的内容

send_window_message<bool>是否发送Windows消息,仅非模拟模式有效

sent_raw<bool>是否发送原始按键,仅非模拟模式有效

wait_mili_seconds<int>字符间输入间隔(毫秒),仅在模拟输入下有效,默认值为20,最大值100,该值设置过大可能会引起超时

timeout<int>等待控件超时时间,单位秒

调用样例- rpa.ui.win32.Window.input_text-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.input_text("记事本输入框", "测试一下")

input_hotkeys

input_hotkeys(element, value, replace=False, index=1, parent_element=None, timeout=10)

方法描述

向控件输入快捷键

参数说明

element<str>控件名

value<str>输入的内容

replace<bool>是否清空之前的内容

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

调用样例- rpa.ui.win32.Window.input_hotkeys-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.input_hotkeys("记事本输入框", "VK_BACK")

drive_input

drive_input(element, value, replace=True, index=1, parent_element=None, wait_mili_seconds=20, timeout=10)

方法描述

以驱动输入的方式向控件中输入文本

参数说明

element<str>控件名

value<str>输入的内容

replace<bool>是否清空之前的内容

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

wait_mili_seconds<int>字符间输入间隔(毫秒),仅在模拟输入下有效,默认值为20,最大值100,该值设置过大可能会引起超时

timeout<int>等待控件超时时间,单位秒

调用样例- rpa.ui.win32.Window.drive_input-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.drive_input("记事本输入框", "RpaTest")

click

click(element, button='left', simulate=True, offset_x=0, offset_y=0, index=1, parent_element=None, timeout=10)

方法描述

点击控件,默认点击控件中心,可通过设定偏移量点击指定位置

参数说明

element<str>控件名

index<int>如果有多个,给出控件下标

simulate<bool>是否模拟点击

offset_x<int>横向偏移量

offset_y<int>纵向偏移量

button<str>鼠标键位

可选项:

  • left : 左键

  • right : 右键

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

调用样例- rpa.ui.win32.Window.click-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.click("记事本输入框")

double_click

double_click(element, offset_x=0, offset_y=0, index=1, parent_element=None, simulate=True, timeout=10)

方法描述

双击控件,默认双击控件中心,可通过设定偏移量双击指定位置

参数说明

element<str>控件名

offset_x<int>横向偏移量

offset_y<int>纵向偏移量

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

simulate<bool>是否模拟点击

timeout<int>等待控件超时时间,单位秒

调用样例- rpa.ui.win32.Window.double_click-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.double_click("记事本输入框")

expand

expand(element, index=1, parent_element=None, timeout=10)

方法描述

控件展开节点

参数说明

element<str>控件名

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

调用样例- rpa.ui.win32.Window.expand-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.expand("控件名称")

collapse

collapse(element, index=1, parent_element=None, timeout=10)

方法描述

控件折叠节点

参数说明

element<str>控件名

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间

调用样例- rpa.ui.win32.Window.collapse-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.collapse("控件名称")

set_selected_item_by_text

set_selected_item_by_text(element, text, index=1, parent_element=None, timeout=10)

方法描述

combobox--根据指定文本选中下拉列表中的项

参数说明

element<str>控件名

text<str>选项文本

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

调用样例- rpa.ui.win32.Window.set_selected_item_by_text-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.set_selected_item_by_text("控件名称", "选择内容")

set_selected_item_by_index

set_selected_item_by_index(element, item_index, index=1, parent_element=None, timeout=10)

方法描述

combobox--根据指定下标选中下拉列表中的项

参数说明

element<str>控件名

item_index<int>选项下标

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

调用样例- rpa.ui.win32.Window.set_selected_item_by_index-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.set_selected_item_by_index("控件名称", "要选择内容的序号")

get_selected_items

get_selected_items(element, mode='selected', index=1, parent_element=None, timeout=10)

方法描述

获取combobox的所有选项或者所有选中的选项

参数说明

element<str>控件名

mode<str>选择模式

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

返回值说明

返回选项的数组<list>

调用样例- rpa.ui.win32.Window.get_selected_items-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
selected_items = wnd.get_selected_items("控件名称")

set_checked_state

set_checked_state(element, value=True, index=1, parent_element=None, timeout=10)

方法描述

设置复选框状态

参数说明

element<str>控件名

value<bool>是否勾选

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

调用样例- rpa.ui.win32.Window.set_checked_state-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.set_checked_state("控件名称", value=True)

get_checked_state

get_checked_state(element, index=1, parent_element=None, timeout=10)

方法描述

获取复选框状态

参数说明

element<str>控件名

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

返回值说明

返回复选框的状态<bool>

调用样例- rpa.ui.win32.Window.get_checked_state-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
checked_state = wnd.get_checked_state("控件名称")

get_selected

get_selected(element, index=1, parent_element=None, timeout=10)

方法描述

获取选中状态

参数说明

element<str>控件名

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

返回值说明

返回是否选中<bool>

调用样例- rpa.ui.win32.Window.get_selected-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
checked_state = wnd.get_selected("控件名称")

text

text(element, index=1, parent_element=None, timeout=10)

方法描述

获取控件中的文本

参数说明

element<str>控件名

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

返回值说明

返回文本<str>

调用样例- rpa.ui.win32.Window.text-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
text = wnd.text("控件名称")

pos

pos(element, index=1, parent_element=None, timeout=10)

方法描述

获取控件的坐标

参数说明

element<str>控件名

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

返回值说明

返回坐标{x1,y1,x2,y2}<dict>

调用样例- rpa.ui.win32.Window.pos-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
pos = wnd.pos("控件名称")

table

table(element, index=1, parent_element=None, timeout=10)

方法描述

获取控件表格内容

参数说明

element<str>控件名

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

返回值说明

返回表格内容<list>

调用样例- rpa.ui.win32.Window.table-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
table_list = wnd.table("控件名称")

scroll

scroll(element, percent, direction='top', index=1, parent_element=None, timeout=10)

方法描述

将滚动条滚动到指定位置(位置范围0-100),由于windows系统底层接口问题,设置的值可能会和实际值存在正负1%的偏差

参数说明

element<str>控件名

percent<int/float>滚动百分比

可选项:

  • top : 向上滚动

  • left : 向下滚动

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

调用样例- rpa.ui.win32.Window.scroll-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.scroll("控件名称", 50)

get_horizontal_scroll_percent

get_horizontal_scroll_percent(element, index=1, parent_element=None, timeout=10)

方法描述

获取横向滚动条位置(位置范围0-100)

参数说明

element<str>控件名

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

返回值说明

返回横向滚动条位置<float>

调用样例- rpa.ui.win32.Window.get_horizontal_scroll_percent-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
horizontal_scroll_percent = wnd.get_horizontal_scroll_percent("控件名称")

get_vertical_scroll_percent

get_vertical_scroll_percent(element, index=1, parent_element=None, timeout=10)

方法描述

获取纵向滚动条位置(位置范围0-100)

参数说明

element<str>控件名

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

返回值说明

返回纵向滚动条位置<float>

调用样例- rpa.ui.win32.Window.get_vertical_scroll_percent-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
horizontal_scroll_percent = wnd.get_vertical_scroll_percent("控件名称")

screenshot

screenshot(element, file, index=1, parent_element=None, timeout=10)

方法描述

控件截图

参数说明

element<str>控件名

file<str>保存截图完成路径(含文件名)

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

调用样例- rpa.ui.win32.Window.screenshot-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.screenshot("控件名称", "d:\1.png")

mouse_move

mouse_move(element, index=1, parent_element=None, timeout=10)

方法描述

鼠标移入控件

参数说明

element<str>控件名

index<int>如果有多个,给出控件下标

parent_element<Element>父控件对象

timeout<int>等待控件超时时间,单位秒

调用样例- rpa.ui.win32.Window.mouse_move-

# 注意事项:无
# 代码调用样例如下:
wnd = rpa.ui.win32.catch("记事本", mode="substr")
wnd.mouse_move("控件名称")

  • 本页导读 (0)
文档反馈