qt4c.control

控件基类模块

Module Contents

Classes

Control 控件基类
ControlContainer 控件集合接口
class qt4c.control.Control

Bases: object

控件基类

_timeout
Children

返回此控件的子控件。需要在子类中实现。

BoundingRect

返回窗口大小。未实现!

_click(self, mouseFlag, clickType, xOffset, yOffset)

点击控件

参数:
  • mouseFlag (qt4c.mouse.MouseFlag) – 鼠标按钮
  • clickType (qt4c.mouse.MouseClickType) – 鼠标动作
  • xOffset (int) – 距离控件区域左上角的偏移。 默认值为None,代表控件区域x轴上的中点; 如果为负值,代表距离控件区域右边的绝对值偏移;
  • yOffset (int) –
    距离控件区域左上角的偏移。
    默认值为None,代表控件区域y轴上的中点;

    如果为负值,代表距离控件区域上边的绝对值偏移;

click(self, mouseFlag=MouseFlag.LeftButton, clickType=MouseClickType.SingleClick, xOffset=None, yOffset=None)

点击控件

参数:
  • mouseFlag (qt4c.mouse.MouseFlag) – 鼠标按钮
  • clickType (qt4c.mouse.MouseClickType) – 鼠标动作
  • xOffset (int) – 距离控件区域左上角的偏移。默认值为None,代表控件区域x轴上的中点。 如果为负值,代表距离控件区域右上角的x轴上的绝对值偏移。
  • yOffset (int) – 距离控件区域左上角的偏移。 默认值为None,代表控件区域y轴上的中点。如果为负值,代表距离控件区域右上角的y轴上的绝对值偏移。
_getClickXY(self, xOffset, yOffset)

通过指定的偏移值确定具体要点击的x,y坐标

doubleClick(self, xOffset=None, yOffset=None)

左键双击,参数参考click函数

hover(self)

鼠标移动到该控件上

rightClick(self, xOffset=None, yOffset=None)

右键双击,参数参考click函数

drag(self, toX, toY)

拖拽控件到指定位置

scroll(self, backward=True)

发送鼠标滚动命令

sendKeys(self, keys)

发送按键命令

setFocus(self)

设控件为焦点

waitForValue(self, prop_name, prop_value, timeout=10, interval=0.5, regularMatch=False)

等待控件属性值出现, 如果属性为字符串类型,则使用正则匹配

参数:
  • prop_name – 属性名字
  • prop_value – 等待出现的属性值
  • timeout – 超时秒数, 默认为10
  • interval – 等待间隔,默认为0.5
  • regularMatch – 参数 property_name和waited_value是否采用正则表达式的比较。默认为不采用(False)正则,而是采用恒等比较。
equal(self, other)

判断两个对象是否相同。未实现!

参数:other (Control) – 本对象实例
__eq__(self, other)

重载对象恒等操作符(==)

__ne__(self, other)

重载对象不等操作符(!=)

get_metis_view(self)

返回MetisView

class qt4c.control.ControlContainer

Bases: object

控件集合接口

当一个类继承本接口,并设置Locator属性后,该类可以使用Controls属于获取控件。如

>>>class SysSettingWin(uia.UIAWindows, ControlContainer)
def __init__(self):
locators={‘常规页’: {‘type’:uia.Control, ‘root’:self, ‘locator’=’PageBasicGeneral’},
‘退出程序单选框’: {‘type’:uia.RadioButton, ‘root’:’@常规页’,’locator’=QPath(“/name=’ExitPrograme_RI’ && maxdepth=’10’”)}}

self.updateLocator(locators)

则SysSettingWin().Controls[‘常规页’]返回设置窗口上常规页的uia.Control实例, 而SysSettingWin().Controls[‘退出程序单选框’],返回设置窗口的常规页下的退出程序单选框实例。 其中’root’=’@常规页’中的’@常规页’表示参数’root’的值不是这个字符串,而是key’常规页’指定的控件。

Controls

返回控件集合。使用如foo.Controls[‘最小化按钮’]的形式获取控件

__findctrl_recur(self, ctrlkey)
__getitem__(self, index)

获取index指定控件

参数:index (string) – 控件索引,如’查找按钮’
clearLocator(self)

清空控件定位参数

hasControlKey(self, control_key)

是否包含控件control_key

返回类型:boolean
updateLocator(self, locators)

更新控件定位参数

参数:locators (dict) – 定位参数,格式是 {‘控件名’:{‘type’:控件类, 控件类的参数dict列表}, …}
isChildCtrlExist(self, childctrlname)

判断指定名字的子控件是否存在

参数:childctrlname (str) – 指定的子控件名称
返回类型:boolean