qt4c.wincontrols

Window的控件模块

Module Contents

Classes

_CWindow Win32 Window类(bridge)
Control Win32 Window类,实现Win32窗口常用属性。
ListViewItem sysListView32的每一项
ListView sysLisView32 控件类型
TextBox 编辑控件
Window Win32 Window类,实现Win32窗口常用属性。
TrayNotifyBar 系统的通知区域
TrayTaskBar 系统的任务栏区域(win7以上不可用)
_TrayIcon 通知栏或任务栏的项
ComboBox ComboBox 控件类型
TreeView Sys TreeView 32 控件类型
TreeViewItem TreeView Item类,不要直接实例化这个类,而通过TreeView.Items来获取。
_ITEMLIST Built-in mutable sequence.
MenuItem 菜单项控件。不要直接实例化这个类,而通过Menu.MenuItems来获取。
Menu 菜单控件
class qt4c.wincontrols._CWindow(hwnd)

Bases: object

Win32 Window类(bridge)

HWnd

窗口句柄

class qt4c.wincontrols.Control(root=None, locator=None)

Bases: qt4c.control.Control

Win32 Window类,实现Win32窗口常用属性。

BoundingRect

返回窗口大小

返回类型:util.Rectangle
返回:util.Rectangle实例
Caption

返回窗口标题

返回类型:StringType
返回:窗口标题
Children

返回子控件列表

返回类型:ListType
ClassName

返回窗口类名

ControlId

返回控件ID

Enabled

此控件是否可用

ExStyle

此控件的扩展样式

HWnd
hwnd
Parent

返回父窗口

返回类型:Window
返回:获取父窗口
Attention:如果是desktop窗口,则返回None;如果是顶级窗口,则返回desktop窗口;否则返回父窗口 。
ProcessId
Style

此控件的样式

Text
ThreadId

窗口线程ID

TopLevelWindow

返回控件的最上层窗口

返回类型:Window
Valid

窗口是否存在

Visible

此控件是否可见

AccessibleObject

返回AccessibleObject

返回类型:qt4c.accessible.AccessibleObject
Width

宽度

Height

高度

_init_wndobj(self)

初始化Win32窗口对象

static __enum_childwin_callback(hwnd, hwnds)
__validCtrlNum(self, ctrls)
equal(self, other)

判断两个对象是否相同。

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

判断控件是否存在

wait_for_exist(self, timeout, interval)

等待控件存在

waitForExist(self, timeout, interval)

等待控件存在

wait_for_invalid(self, timeout=10.0, interval=0.5)

等待控件失效

waitForInvalid(self, timeout=10.0, interval=0.5)

等待控件失效

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轴上的绝对值偏移;

setFocus(self)

将此控件设为焦点

class qt4c.wincontrols.ListViewItem(parent, item_index)

Bases: qt4c.control.Control

sysListView32的每一项

SubItems
BoundingRect

获取ListView的某项Item的文本

Text

获取ListView的某项Item的文本

class qt4c.wincontrols.ListView(root=None, locator=None)

Bases: qt4c.wincontrols.Control

sysLisView32 控件类型

ItemCount

The number of items in the ListView

Items
__iter__(self)
__getitem__(self, key)
class qt4c.wincontrols.TextBox(root=None, locator=None)

Bases: qt4c.wincontrols.Control

编辑控件

class qt4c.wincontrols.Window(root=None, locator=None)

Bases: qt4c.wincontrols.Control, qt4c.control.ControlContainer

Win32 Window类,实现Win32窗口常用属性。

Maximized

该窗口是否最大化

Minimized

该窗口是否最小化

OwnerWindow

此窗口的所有者窗口

返回类型:Window
返回:获取Owner Window
PopupWindow

此窗口的弹出窗口

返回类型:Window
返回:获取EnabledPopup
TopMost

是否具有总在最前端

bringForeground(self)

将窗口设为最前端窗口

_wait_for_disabled_or_invisible(self, timeout=60, interval=0.5)
close(self)

关闭窗口

返回类型:bool
返回:窗口销毁返回True,否则返回False
hide(self)

隐藏

maximize(self)

最大化窗口

minimize(self)

最小化窗口

resize(self, width, height)

设置窗口大小

restore(self)

恢复窗口

show(self)

显示窗口

move(self, x, y)

移动窗口

waitForInvalid(self, timeout=10.0, interval=0.5)

等待窗口失效

参数:timeout (float) – 超时秒数
waitForInvisible(self, timeout=10.0, interval=0.5)

等待窗口消失

参数:timeout (float) – 超时秒数
class qt4c.wincontrols.TrayNotifyBar

Bases: qt4c.wincontrols.Control

系统的通知区域

Items

返回TrayNotifyBar的全部TrayNotifyIcon

refresh(self)

刷新通知区域

__getitem__(self, key)
class qt4c.wincontrols.TrayTaskBar

Bases: qt4c.wincontrols.Control

系统的任务栏区域(win7以上不可用)

Items

返回TrayTaskBar的全部TrayNotifyIcon

__getitem__(self, key)
class qt4c.wincontrols._TrayIcon(tbButton, trayData, notifyBar)

Bases: qt4c.control.Control

通知栏或任务栏的项

BoundingRect

托盘图标的位置

返回类型:util.Rectangle
返回:util.Rectangle
ProcessId

图标所代表的进程Id

State

图标状态,隐藏or显示

Style

图标风格,分隔符or自定义图片之类

Tips

图标提示

Visible

是否可见

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轴上的绝对值偏移;

destroy(self)

销毁该图标使之不再显示

equal(self, other)

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

参数:other (Control) – 本对象实例
class qt4c.wincontrols.ComboBox(root=None, locator=None)

Bases: qt4c.wincontrols.Control

ComboBox 控件类型

Count

返回ComboBox的项目数

SelectedIndex

返回当选选中的索引值

_getTextByIndex(self, idx=-1)
getFullPath(self)
class qt4c.wincontrols.TreeView(root=None, locator=None)

Bases: qt4c.wincontrols.Control

Sys TreeView 32 控件类型

Items

返回TreeView的首层节点列表

返回类型:list
count(self)

返回TreeView的item数

class qt4c.wincontrols.TreeViewItem(hwnd, item)

Bases: qt4c.control.Control

TreeView Item类,不要直接实例化这个类,而通过TreeView.Items来获取。

HWnd

窗口句柄

hwnd

窗口句柄

BoundingRect

返回窗口大小。未实现!

Items
Selected
Text
NextSibling
ensureVisible(self)

先保证item完全可见

select(self)

选中自身结点

class qt4c.wincontrols._ITEMLIST

Bases: list

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

__getitem__(self, key)

x.__getitem__(y) <==> x[y]

class qt4c.wincontrols.MenuItem(menu, index)

Bases: qt4c.wincontrols.Control

菜单项控件。不要直接实例化这个类,而通过Menu.MenuItems来获取。

class EnumMenuItemState

Bases: object

DISABLED = Disabled
GRAYED = Grayed
NORMAL = Normal
UNKNOWN = Unknown
IsSeperator

返回该子项是否是分割线

State

返回菜单项的状态

返回类型:EnumMenuItemState
Text

可见文本

SubMenu

鼠标移动到该子项上,产生子菜单,并返回该子菜单

返回类型:Menu
BoundingRect

返回rect

static __enum_childwin_callback(hwnd, hwnds)
__getSysMenuWindow(self)
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轴上的绝对值偏移;

class qt4c.wincontrols.Menu(root=None, locator=None)

Bases: qt4c.wincontrols.Window

菜单控件

MenuItems

获取MenuItem。通过MenuItems[菜单项索引]或MenuItems[菜单项文字]返回MenuItem实例。

_getSubMenuItemsCount(self)
__findSysMenuWindow(self)
static closeAllSysMenuWindow()

关闭所有的系统menu窗口

static __enum_childwin_callback(hwnd, hwnds)
__iter__(self)
__getitem__(self, key)

根据key返回MenuItem key: 菜单索引或菜单文字