Repository: fangchaooo/zh-pywinauto-doc Branch: master Commit: 6371954a5ad7 Files: 7 Total size: 47.2 KB Directory structure: gitextract_pxirvoth/ ├── Basic User Input Mod.md ├── How To's.md ├── Main User Modules.md ├── Methods available to each different control type.md ├── README.md ├── Waiting for Long Operations.md └── What is pywinauto.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: Basic User Input Mod.md ================================================ # 用户基本输入模块 [TOC] ## pywinauto.mouse 跨平台来模拟鼠标事件 `pywinauto.mouse.click(*button='left', coords=(0, 0))` 点击指定的坐标 `pywinauto.mouse.click(*button='left', coords=(0, 0))` ## pywinauto.keyboard 键盘输入仿真模块 通过调用`SendKeys`方法自动将键入到活动窗口。您可以使用任何Unicode字符(在Windows上)和下面列出的一些特殊键。该模块也可在Linux上使用。 可用键码: ``` { SCROLLLOCK }, { VK_SPACE }, { VK_LSHIFT }, { VK_PAUSE }, { VK_MODECHANGE }, { BACK }, { VK_HOME }, { F23 }, { F22 }, { F21 }, { F20 }, { VK_HANGEUL }, { VK_KANJI }, { VK_RIGHT }, { BS }, { HOME }, { VK_F4 }, { VK_ACCEPT}, { VK_F18 }, { VK_SNAPSHOT }, { VK_PA1 }, { VK_NONAME }, { VK_LCONTROL }, { ZOOM }, { VK_ATTN }, { VK_F10 }, { VK_F22 }, { VK_F23 }, { VK_F20 }, { VK_F21 } { VK_SCROLL }, { TAB }, { VK_F11 }, { VK_END }, { LEFT }, {VK_UP }, { NUMLOCK }, { VK_APPS }, { PGUP }, { VK_F8 }, { VK_CONTROL }, { VK_LEFT }, { PRTSC }, { VK_NUMPAD4 }, { CAPSLOCK }, { VK_CONVERT }, { VK_PROCESSKEY }, { ENTER } , { VK_SEPARATOR }, { VK_RWIN }, { VK_LMENU }, { VK_NEXT }, { F1}, { F2 }, { F3 }, { F4 }, { F5 }, { F6 }, { F7 }, { F8 }, { F9 }, { VK_ADD }, { VK_RCONTROL }, { VK_RETURN }, { BREAK }, { VK_NUMPAD9 }, { VK_NUMPAD8 }, { RWIN }, { VK_KANA }, { PGDN }, { VK_NUMPAD3}, { DEL }, { VK_NUMPAD1 }, { VK_NUMPAD0 }, { VK_NUMPAD7 }, { VK_NUMPAD6 }, { VK_NUMPAD5 }, { DELETE }, { VK_PRIOR }, { VK_SUBTRACT }, { HELP }, { VK_PRINT }, { VK_BACK } { CAP }, { VK_RBUTTON }, { VK_RSHIFT }, { VK_LWIN }, { DOWN }, { VK_HELP }, { VK_NONCONVERT }, { BACKSPACE }, { VK_SELECT }, { VK_TAB }, { VK_HANJA }, { VK_NUMPAD2 }, { INSERT }, { VK_F9 }, { VK_DECIMAL }, { VK_FINAL }, { VK_EXSEL }, { RMENU }, { VK_F3 }, { VK_F2 }, { VK_F1 }, { VK_F7 }, {VK_F6 }, { VK_F5 }, { VK_CRSEL }, { VK_SHIFT }, { VK_EREOF }, { VK_CANCEL }, { VK_DELETE }, { VK_HANGUL }, { VK_MBUTTON }, { VK_NUMLOCK }, { VK_CLEAR }, { END }, { VK_MENU } , { SPACE }, { BKSP }, { VK_INSERT }, { F18 }, { F19}, { ESC }, { VK_MULTIPLY }, { F12 }, { F13 }, { F10 }, { F11 }, { F16 }, { F17 }, { F14 }, { F15 }, { F24 }, { RIGHT } { VK_F24 }, { VK_CAPITAL }, { VK_LBUTTON }, { VK_OEM_CLEAR }, { VK_ESCAPE }, { UP}, { VK_DIVIDE }, { INS }, { VK_JUNJA }, { VK_F19 }, { VK_EXECUTE }, { VK_PLAY }, { VK_RMENU }, { VK_F13 }, { VK_F12 }, { 伦}, { VK_DOWN }, { VK_F17 } { VK_F16 }, { VK_F15 }, { VK_F14 } ``` **修饰符:** - `'+': {VK_SHIFT}` - `'^': {VK_CONTROL}` - `'%': {VK_MENU}` 又名Alt键 示例如何使用修饰符: ```python SendKeys('^a^c') # select all (Ctrl+A) and copy to clipboard (Ctrl+C) SendKeys('+{INS}') # insert from clipboard (Shift+Ins) SendKeys('%{F4}') # close an active window with Alt+F4 ``` 可以为特殊键指定重复计数。`{ENTER 2}`意思是按两次Enter ================================================ FILE: How To's.md ================================================ # How To‘s [TOC] ### 指定可用的Application实例 一个`Application`实例是所有使用这个你正在自动化操作的应用程序的联系者。因此这个应用程序实例需要连接到进程中,有下面两种方法实现: `start (self , cmd_line , timeout = app_start_timeout ) ` `connect (self , ** kwargs ) ` `start()`被用来在这个程序没有运行但你需要启动它的时候 `app = Application().start(r"c:\path\to\your\application -a -n -y --arguments")` 其中超时参数是可选的,如果应用程序需要很长时间来启动,则只需要使用该参数。 `connect()`是当自动化程序已经启动时来使用,要指定以运行的应用程序你需要指定以下选项之一: - 进程: 应用的过程ID `app = Application().connect(process=2341)` - 句柄:应用程序的窗口句柄 `app = Application().connect(handle=0x010f0c)` - 路径:进程中可执行文件路径(`GetModuleFileNameEx`)用于查找每个进程的路径并将其传入的值进行比较) `app = Application().connect (path = r “c:\ windows \ system32 \ notepad.exe” )` 或任何窗口参数的组合,都会传递给[`pywinauto.findwindows.find_elements()`](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.findwindows.html#pywinauto.findwindows.find_elements)函数,例如: `app = Application().connect (title_re = “。* Notepad” , class_name = “Notepad” )` 注意:应用程序在你使用`connect()`之前必须准备好。在`start()`执行之后寻找应用程序,它是没有超时或重试的。因此,如果你在`pywinauto`之外启动程序,你需要睡眠或者编写一个循环等待来等待应用程序完全启动。 ### 如何制定应用程序的对话框 一旦应用程序实例知道了被连接的窗口在工作,那么就需要指定这个窗口。 例如: `dlg = app.Notepad` `dlg = app['Notepad']` 接下来是一个最简单的方法,去询问`top_window()`函数 `dlg = app.top_window()` 它将返回这个应用程序最高层级的窗口 **注意:这是目前尚未测试的,所以我们并不清楚它是否会正确的返回** 如果上述还不能进行有效控制,那么你可以使用项目参数传递给`findwindows.find.window()` `dlg = app.window(title_re="Page Setup", class_name="#32770")` 最后介绍一个你可以进行多控制的方法 `dialogs = app.windows()` 这将返回应用程序中所有可见,启用的顶层窗口列表,然后你就可以使用`handleprops`模块中的某些方法所选用的对话框,一旦你拥有其句柄,就可以使用 `app.window(handle=win)` **注意:如果对话框的标题很长,那么访问属性可能会是很长的类型,在此情况下,通常使用** `app.window(title_re=".*Part of Title.*")` ### 如何在对话框上指定控件 有很多方法,最简单的就是 ```python app.dlg.control app['dlg']['control'] ``` 对非英文的环境来说,需要传递`unicode`字符,则 `app[u'your dlg title'][u'your ctrl title']` 代码依据如下内容来构建多个标识符: - 标题 - 相关类 - 标题 + 相关类 如果标签的文本为空(或者删除不能使用的字符后为),那么文本就不能被使用。相反,我们会寻找上面和最右边的控制,并附加其相关类,所以列表就是: - 相关类 - 联系最紧密的文字+ 相关类 一旦对话框中所有控件创建了一组标识符,我们就将它们消除歧义 使用`WindowSpecification.print_control_identifiers() ` 例如 ```python dlg_spec = app['无标题 - 记事本'] dlg_spec.print_control_identifiers() >>> Control Identifiers: Dialog - '无标题 - 记事本' (L481, T434, R1281, B802) ['无标题 - 记事本Dialog', 'Dialog', '无标题 - 记事本'] child_window(title="无标题 - 记事本", control_type="Window") | | Edit - '文本编辑器' (L489, T485, R1273, B794) | ['', 'Edit', '0', '1'] | child_window(title="文本编辑器", auto_id="15", control_type="Edit") | | | | ScrollBar - '垂直滚动条' (L1256, T485, R1273, B794) | | ['垂直滚动条ScrollBar', '垂直滚动条', 'ScrollBar'] | | child_window(title="垂直滚动条", auto_id="NonClientVerticalScrollBar", control_type="ScrollBar") | | | | | | Button - '上一行' (L1256, T485, R1273, B502) | | | ['上一行', '上一行Button', 'Button', 'Button0', 'Button1'] | | | child_window(title="上一行", auto_id="UpButton", control_type="Button") | | | | | | Button - '下一行' (L1256, T777, R1273, B794) | | | ['下一行', '下一行Button', 'Button2'] | | | child_window(title="下一行", auto_id="DownButton", control_type="Button") | | TitleBar - 'None' (L505, T437, R1273, B465) | ['2', 'TitleBar'] | | | | Menu - '系统' (L489, T442, R511, B464) | | ['系统Menu', '系统', 'Menu', '系统0', '系统1', 'Menu0', 'Menu1'] | | child_window(title="系统", auto_id="MenuBar", control_type="MenuBar") | | | | | | MenuItem - '系统' (L489, T442, R511, B464) | | | ['系统2', 'MenuItem', '系统MenuItem', 'MenuItem0', 'MenuItem1'] | | | child_window(title="系统", control_type="MenuItem") | | | | Button - '最小化' (L1134, T435, R1181, B465) | | ['最小化Button', '最小化', 'Button3'] | | child_window(title="最小化", control_type="Button") | | | | Button - '最大化' (L1181, T435, R1227, B465) | | ['最大化Button', '最大化', 'Button4'] | | child_window(title="最大化", control_type="Button") | | | | Button - '关闭' (L1227, T435, R1274, B465) | | ['关闭', '关闭Button', 'Button5'] | | child_window(title="关闭", control_type="Button") | | Menu - '应用程序' (L489, T465, R1273, B484) | ['应用程序', 'Menu2', '应用程序Menu'] | child_window(title="应用程序", auto_id="MenuBar", control_type="MenuBar") | | | | MenuItem - '文件(F)' (L489, T465, R541, B484) | | ['文件(F)MenuItem', 'MenuItem2', '文件(F)'] | | child_window(title="文件(F)", control_type="MenuItem") | | | | MenuItem - '编辑(E)' (L541, T465, R594, B484) | | ['MenuItem3', '编辑(E)', '编辑(E)MenuItem'] | | child_window(title="编辑(E)", control_type="MenuItem") | | | | MenuItem - '格式(O)' (L594, T465, R650, B484) | | ['格式(O)', '格式(O)MenuItem', 'MenuItem4'] | | child_window(title="格式(O)", control_type="MenuItem") | | | | MenuItem - '查看(V)' (L650, T465, R704, B484) | | ['查看(V)MenuItem', '查看(V)', 'MenuItem5'] | | child_window(title="查看(V)", control_type="MenuItem") | | | | MenuItem - '帮助(H)' (L704, T465, R759, B484) | | ['帮助(H)', 'MenuItem6', '帮助(H)MenuItem'] | | child_window(title="帮助(H)", control_type="MenuItem") ``` 注意:此方法打印的标识符已经通过标识的唯一进程。所以如果你有两个编辑框,它们都会在其中列出。实际上,第一个可以被称之为“编辑”,“编辑0”,“编辑1”和第二个应该被称为“编辑2” 注意:你不需要精确! ### 如何使用pywinauto在英文之外的环境 在py2中,Python的编码一直是蛋疼的问题,但是py3的出现改变了这一现状。Python3中,字符串是以Unicode编码的,也就是说,Python的字符串支持多语言。使用如下方法来进行属性控制 > 在英文文档中,此部分还是以Python2为基础 1. `app.dialog_ident.control_ident.click()` 2. `app['dialog_ident']['control_ident'].click()` 3. `app.window(title_re="NonAsciiCharacters").window(title="MoreNonAsciiCharacters").click()` ### 如何处理不按照预期进行响应的控件(例如OwnerDraw控件) 一些控件不按照预期的方式响应事件。例如,如果你查看任何HLP文件,并转到索引选项(单击”搜索“按钮),您将会看见一个列表框。运行控件查看工具(spy++)你就发现它确实是一个列表,但是是`ownerdrawn`。这意味着开发人员以及告诉windows,它们会覆盖项目的显示方式。在这种情况下,这样的一些字符串无法被检索。 这些问题是怎么导致的那? ```python app.HelpTopics.ListBox.texts() # 1 app.HelpTopics.ListBox.select("ItemInList") # 2 ``` 1. 这将返回空字符串的列表,这意味着`pywinauto`无法获取列表框中的字符串 2. 这将因为`IndexError`而失败,因为`ListBox`中的`select(string)`模块查找文本中的项目去了解其索引。 应用此控件的解决方法: `app.HelpTopics.ListBox.select(1)` 这将选择列表框中的第二个项目,因为这不是正确的查找字符串。 不幸的是,它永远不会工作。开发人员可以使其控制不响应事件,如`select`。在这种情况下,您可以使用`TypeKeys()`的键盘模拟来选择列表框中的项目。 这允许您将任何按键发送到控件。所以选择第三个项目你应该使用 `app.Helptopics.ListBox1.type_keys("{HOME}{DOWN 2}{ENTER}")` - `{HOME}` 将确保第一个项目被突出显示。 - `{DOWN 2}` 然后将亮点向下移动两项 - `{ENTER}` 将选择突出显示的项目 如果你的应用程序广泛使用类似的控件类型,那么你可以通过从`ListBox`派生一个新类来简化使用,可以作为你特定程序的额外知识 ### 如何访问系统托盘(SysTray,通知区域) ```python import pywinauto.application app = pywinauto.application.Application().connect(path="explorer") systray_icons = app.ShellTrayWnd.NotificationAreaToolbar ``` 任务栏模块提供对系统托盘的初步访问。 它定义了以下变量: - explorer_app 定义连接到正在运行的资源管理器的`Application()`对象。你可能不需要直接使用它。 - 任务栏 任务栏的句柄(包括开始按钮,QuickLaunch图标,正在运行的任务等) - 开始按钮 “启动我”:-)我想你可能会知道这是什么! - 快速启动 具有快速启动图标的工具栏 - SystemTray中 包含时钟和系统托盘图标的窗口 - 时钟 - SystemTrayIcons 表示系统托盘图标的工具栏 - RunningApplications 工具条表示运行中的应用程序 我还在模块中提供了两个可以用来点击系统托盘图标的功能: - `ClickSystemTrayIcon(button)` 您可以使用此按钮左键单击系统托盘中的可见图标。我不得不具体说可见的图标,因为可能有许多看不见的图标显然不能被点击。按钮可以是任意整数。如果您指定3,那么它会找到并单击第3个可见按钮。(几乎不会在这里执行错误检查,但这种方法将来会更有可能被移动/重命名。) - `RightClickSystemTrayIcon(button)` 类似于`ClickSytemTrayIcon`但执行右键单击。 通常,当您点击/右键单击图标时,您将收到一个弹出菜单。在这一点上要记住的是,弹出菜单是应用程序的一部分,而不是资源管理器的一部分。 例如: ```python # connect to outlook outlook = Application.connect(path='outlook.exe') # click on Outlook's icon taskbar.ClickSystemTrayIcon("Microsoft Outlook") # Select an item in the popup menu outlook.PopupMenu.Menu().get_menu_path("Cancel Server Request")[0].click() ``` ================================================ FILE: Main User Modules.md ================================================ ================================================ FILE: Methods available to each different control type.md ================================================ # Methods available to each different control type Windows有很多控件,按钮,列表等 [TOC] ### 所有控件 这些函数适用于所有控件 - [capture_as_image](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.capture_as_image) - [click](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.click) - [click_input](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.click_input) - [close](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.close) - [close_click](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.close_click) - [debug_message](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.debug_message) - [double_click](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.double_click) - [double_click_input](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.double_click_input) - [drag_mouse](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.drag_mouse) - [draw_outline](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.draw_outline) - [get_focus](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.get_focus) - [get_show_state](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.get_show_state) - [maximize](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.maximize) - [menu_select](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.menu_select) - [minimize](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.minimize) - [move_mouse](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.move_mouse) - [move_window](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.move_window) - [notify_menu_select](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.notify_menu_select) - [notify_parent](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.notify_parent) - [press_mouse](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.press_mouse) - [press_mouse_input](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.press_mouse_input) - [release_mouse](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.release_mouse) - [release_mouse_input](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.release_mouse_input) - [restore](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.restore) - [right_click](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.right_click) - [right_click_input](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.right_click_input) - [send_message](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.send_message) - [send_message_timeout](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.send_message_timeout) - [set_focus](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.set_focus) - [set_window_text](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.set_window_text) - [type_keys](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.type_keys) - [Children](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.Children) - [Class](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.Class) - [ClientRect](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.ClientRect) - [ClientRects](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.ClientRects) - [ContextHelpID](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.ContextHelpID) - [ControlID](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.ControlID) - [ExStyle](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.ExStyle) - [Font](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.Font) - [Fonts](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.Fonts) - [FriendlyClassName](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.FriendlyClassName) - [GetProperties](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.GetProperties) - [HasExStyle](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.HasExStyle) - [HasStyle](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.HasStyle) - [IsChild](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.IsChild) - [IsDialog](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.IsDialog) - [IsEnabled](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.IsEnabled) - [IsUnicode](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.IsUnicode) - [IsVisible](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.IsVisible) - [Menu](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.Menu) - [MenuItem](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.MenuItem) - [MenuItems](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.MenuItems) - [Owner](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.Owner) - [Parent](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.Parent) - [PopupWindow](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.PopupWindow) - [ProcessID](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.ProcessID) - [Rectangle](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.Rectangle) - [Style](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.Style) - [Texts](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.Texts) - [TopLevelParent](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.TopLevelParent) - [UserData](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.UserData) - [VerifyActionable](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.VerifyActionable) - [VerifyEnabled](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.VerifyEnabled) - [VerifyVisible](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.VerifyVisible) - [WindowText](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.hwndwrapper.html#pywinauto.controls.hwndwrapper.HwndWrapper.WindowText) ### 按钮,复选框,单选按钮, 分租框 - [ButtonWrapper.Check](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ButtonWrapper.Check) - [ButtonWrapper.GetCheckState](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ButtonWrapper.GetCheckState) - [ButtonWrapper.SetCheckIndeterminate](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ButtonWrapper.SetCheckIndeterminate) - [ButtonWrapper.UnCheck](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ButtonWrapper.UnCheck) ### 组合框 - [ComboBoxWrapper.DroppedRect](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ComboBoxWrapper.DroppedRect) - [ComboBoxWrapper.ItemCount](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ComboBoxWrapper.ItemCount) - [ComboBoxWrapper.ItemData](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ComboBoxWrapper.ItemData) - [ComboBoxWrapper.ItemTexts](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ComboBoxWrapper.ItemTexts) - [ComboBoxWrapper.Select](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ComboBoxWrapper.Select) - [ComboBoxWrapper.SelectedIndex](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ComboBoxWrapper.SelectedIndex) ### 对话 - [DialogWrapper.ClientAreaRect](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.DialogWrapper.ClientAreaRect) - [DialogWrapper.RunTests](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.DialogWrapper.RunTests) - [DialogWrapper.WriteToXML](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.DialogWrapper.WriteToXML) ### 编辑 - [EditWrapper.GetLine](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.EditWrapper.GetLine) - [EditWrapper.LineCount](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.EditWrapper.LineCount) - [EditWrapper.LineLength](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.EditWrapper.LineLength) - [EditWrapper.Select](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.EditWrapper.Select) - [EditWrapper.SelectionIndices](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.EditWrapper.SelectionIndices) - [EditWrapper.SetEditText](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.EditWrapper.SetEditText) - [EditWrapper.set_window_text](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.EditWrapper.set_window_text) - [EditWrapper.TextBlock](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.EditWrapper.TextBlock) ### 头 - [HeaderWrapper.GetColumnRectangle](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.HeaderWrapper.GetColumnRectangle) - [HeaderWrapper.GetColumnText](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.HeaderWrapper.GetColumnText) - [HeaderWrapper.ItemCount](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.HeaderWrapper.ItemCount) ### 列表框 - [ListBoxWrapper.GetItemFocus](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ListBoxWrapper.GetItemFocus) - [ListBoxWrapper.ItemCount](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ListBoxWrapper.ItemCount) - [ListBoxWrapper.ItemData](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ListBoxWrapper.ItemData) - [ListBoxWrapper.ItemTexts](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ListBoxWrapper.ItemTexts) - [ListBoxWrapper.Select](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ListBoxWrapper.Select) - [ListBoxWrapper.SelectedIndices](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ListBoxWrapper.SelectedIndices) - [ListBoxWrapper.SetItemFocus](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.win32_controls.html#pywinauto.controls.win32_controls.ListBoxWrapper.SetItemFocus) ### 列表显示 - [ListViewWrapper.Check](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.Check) - [ListViewWrapper.ColumnCount](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.ColumnCount) - [ListViewWrapper.Columns](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.Columns) - [ListViewWrapper.ColumnWidths](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.ColumnWidths) - [ListViewWrapper.GetColumn](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.GetColumn) - [ListViewWrapper.GetHeaderControl](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.GetHeaderControl) - [ListViewWrapper.GetItem](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.GetItem) - [ListViewWrapper.GetSelectedCount](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.GetSelectedCount) - [ListViewWrapper.IsChecked](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.IsChecked) - [ListViewWrapper.IsFocused](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.IsFocused) - [ListViewWrapper.IsSelected](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.IsSelected) - [ListViewWrapper.ItemCount](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.ItemCount) - [ListViewWrapper.Items](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.Items) - [ListViewWrapper.Select](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.Select) - [ListViewWrapper.Deselect](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.Deselect) - [ListViewWrapper.UnCheck](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ListViewWrapper.UnCheck) ### 弹出菜单 ### Robar ### 静态栏 ### 状态栏 - [StatusBarWrapper.BorderWidths](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.StatusBarWrapper.BorderWidths) - [StatusBarWrapper.GetPartRect](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.StatusBarWrapper.GetPartRect) - [StatusBarWrapper.GetPartText](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.StatusBarWrapper.GetPartText) - [StatusBarWrapper.PartCount](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.StatusBarWrapper.PartCount) - [StatusBarWrapper.PartRightEdges](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.StatusBarWrapper.PartRightEdges) ### Tab控制 - [TabControlWrapper.GetSelectedTab](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TabControlWrapper.GetSelectedTab) - [TabControlWrapper.GetTabRect](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TabControlWrapper.GetTabRect) - [TabControlWrapper.GetTabState](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TabControlWrapper.GetTabState) - [TabControlWrapper.GetTabText](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TabControlWrapper.GetTabText) - [TabControlWrapper.RowCount](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TabControlWrapper.RowCount) - [TabControlWrapper.Select](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TabControlWrapper.Select) - [TabControlWrapper.TabCount](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TabControlWrapper.TabCount) - [TabControlWrapper.TabStates](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TabControlWrapper.TabStates) ### 工具栏 - [ToolbarWrapper.Button](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ToolbarWrapper.Button) - [ToolbarWrapper.ButtonCount](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ToolbarWrapper.ButtonCount) - [ToolbarWrapper.GetButton](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ToolbarWrapper.GetButton) - [ToolbarWrapper.GetButtonRect](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ToolbarWrapper.GetButtonRect) - [ToolbarWrapper.GetToolTipsControl](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ToolbarWrapper.GetToolTipsControl) - [ToolbarWrapper.PressButton](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ToolbarWrapper.PressButton) ToolbarButton*(返回`Button()`) - [ToolbarButton.Rectangle](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._toolbar_button.Rectangle) - [ToolbarButton.Style](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._toolbar_button.Style) - [ToolbarButton.click_input](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._toolbar_button.click_input) - [ToolbarButton.Click](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._toolbar_button.Click) - [ToolbarButton.IsCheckable](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._toolbar_button.IsCheckable) - [ToolbarButton.IsChecked](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._toolbar_button.IsChecked) - [ToolbarButton.IsEnabled](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._toolbar_button.IsEnabled) - [ToolbarButton.IsPressable](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._toolbar_button.IsPressable) - [ToolbarButton.IsPressed](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._toolbar_button.IsPressed) - [ToolbarButton.State](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._toolbar_button.State) ### 工具提示 - [ToolTipsWrapper.GetTip](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ToolTipsWrapper.GetTip) - [ToolTipsWrapper.GetTipText](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ToolTipsWrapper.GetTipText) - [ToolTipsWrapper.ToolCount](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.ToolTipsWrapper.ToolCount) ### 数视图 - [TreeViewWrapper.EnsureVisible](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TreeViewWrapper.EnsureVisible) - [TreeViewWrapper.GetItem](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TreeViewWrapper.GetItem) - [TreeViewWrapper.GetProperties](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TreeViewWrapper.GetProperties) - [TreeViewWrapper.IsSelected](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TreeViewWrapper.IsSelected) - [TreeViewWrapper.ItemCount](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TreeViewWrapper.ItemCount) - [TreeViewWrapper.Root](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TreeViewWrapper.Root) - [TreeViewWrapper.Select](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.TreeViewWrapper.Select) *TreeViewElement*(由`GetItem()`和返回`Root()`) - [TreeViewElement.Children](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._treeview_element.Children) - [TreeViewElement.Item](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._treeview_element.Item) - [TreeViewElement.Next](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._treeview_element.Next) - [TreeViewElement.Rectangle](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._treeview_element.Rectangle) - [TreeViewElement.State](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._treeview_element.State) - [TreeViewElement.SubElements](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._treeview_element.SubElements) - [TreeViewElement.Text](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls._treeview_element.Text) ### UpDown - [UpDownWrapper.GetBase](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.UpDownWrapper.GetBase) - [UpDownWrapper.GetBuddyControl](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.UpDownWrapper.GetBuddyControl) - [UpDownWrapper.GetRange](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.UpDownWrapper.GetRange) - [UpDownWrapper.GetValue](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.UpDownWrapper.GetValue) - [UpDownWrapper.SetValue](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.UpDownWrapper.SetValue) - [UpDownWrapper.Increment](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.UpDownWrapper.Increment) - [UpDownWrapper.Decrement](https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.common_controls.html#pywinauto.controls.common_controls.UpDownWrapper.Decrement) ================================================ FILE: README.md ================================================ # zh-pywinauto-doc [TOC] [Pywinauto](https://pywinauto.github.io/)的中文翻译。 `Pywinauto`是一个GUI自动化库,它是用`python`写的,而且可以很好的支持Windows GUI。 因为我在做Windows Desktop Application GUI Automation Test用到了这个库,因此顺便翻译了文档。 ## 安装 - 直接使用`pip install --upgrade pywinauto` (Py2.7+, Py3.3+) 或者也可以手动安装: - 安装 [pyWin32 extensions](http://sourceforge.net/projects/pywin32/files/pywin32/) - 下载 [six](https://pypi.python.org/pypi/six)并执行 `python setup.py install`来安装 - 下载 [comtypes](https://github.com/enthought/comtypes/releases) 并执行 `python setup.py install`来安装 - 下载 [the latest pywinauto](https://github.com/pywinauto/pywinauto/zipball/master/) 并执行 `python setup.py install`来安装 或者在Linux下安装: - [six](https://pypi.python.org/pypi/six) - [python-xlib](https://github.com/python-xlib/python-xlib/releases) - 执行 `python setup.py install` 对每一个依赖`pywinauto`的包 ## 支持的控件 - 标准Win32控件:MFC, WTL, VB6和其他一些使用WinForms的老应用 - 所有基于MS UI Automation的标准部件:WPF, Qt, 所有浏览器, Windows文件资源管理器和其他 ## 详细文档 [入门](https://github.com/fangchaooo/zh-pywinauto-doc/blob/master/What%20is%20pywinauto.md) [怎样使用](https://github.com/fangchaooo/zh-pywinauto-doc/blob/b83093cf125240ceff2fde5f7fe5ef26d0d4fcfc/How%20To's.md) [等待操作](https://github.com/fangchaooo/zh-pywinauto-doc/blob/b83093cf125240ceff2fde5f7fe5ef26d0d4fcfc/Waiting%20for%20Long%20Operations.md) [各种不同控件类型可用模块](https://github.com/fangchaooo/zh-pywinauto-doc/blob/b83093cf125240ceff2fde5f7fe5ef26d0d4fcfc/Methods%20available%20to%20each%20different%20control%20type.md) ================================================ FILE: Waiting for Long Operations.md ================================================ # Waiting for Long Operations [TOC] GUI应用程序行为通常是不稳定的,您的脚本需要等待直到出现新窗口或现有窗口被关闭/隐藏。pywinauto可以隐含地等待对话初始化(默认超时)。有几种方法/功能可以帮助您使代码更容易,更可靠。 ### 申请方式 - `wait_cpu_usage_lower` 该方法对于允许在另一个线程中进行延迟初始化的多线程接口是有用的,而GUI响应并且所有控件已经存在并且可以使用。所以等待一个特定的窗口存在/状态是无用的。在这种情况下,整个过程的CPU使用情况表明任务计算尚未完成. `app.wait_cpu_usage_lower(threshold=5) # 等到CPU使用率低于5%` ### WindowSpecification方法 所有控件都可以使用 - `wait` - `wait_not` 一个`WindowSpecification`对象不一定与现有的窗口/控件相关。这只是一个描述,即搜索窗口的几个条件。该`wait`方法(如果没有引发任何异常)可以保证目标控件存在,甚至可见,启用或活动。 ### `timings`模块功能 对任何Python代码都有用的低级方法 - wait_until - wait_until_passes 装饰器`pywinauto.timings.always_wait_until()`和`pywinauto.timings.always_wait_until_passes()`可以被每个函数进行调用。 ```python #call ensure_text_changed(ctrl)每2秒,直到通过或超时(4秒)过期 @always_wait_until_passes(4, 2) def ensure_text_changed(CTRL): if previous_text == CTRL 。window_text(): raise ValueError ('ctrl文本保持不变而改变是预期的') ``` ### 识别控制 帮你找到所需控件的方法。 - `print_control_identifiers` - `draw_outline` ================================================ FILE: What is pywinauto.md ================================================ # PYWINAUTO入门指南 [TOC] > windows上支持的辅助技术列表 > > - Win32 API(`backend = "win32"`)(现在默认) > - MFC VB6 VCL > - MS UI Automation(`backend = "uia"`) > - WinForms, WPF, Store app, QT, Browsers > > GUI观察 > > - spy++ > > - Inspect.exe > > 路径在`C:\Program Files (x86)\Windows Kits\\bin\x64` > > ​ > > 如果GUI不能满足你的要求,那使用鼠标和键盘模块也是另一种选择,使用[pyautogui](https://github.com/asweigart/pyautogui)吧,它可以满足你任何要求。 ### 自动化入口 在`pywinauto`中启动程序使用一个`Application`对象来调用它。 ```python from pywinauto.application import Application # 对于Windows中自带应用程序,直接执行,对于外部应用应输入完整路径 app = Application(backend="uia").start('notepad.exe') #描述Notepad.exe进程中的窗口 dlg_spec = app.UntitledNotepad #等待窗口真正打开 actionable_dlg = dlg_spec.wait('visible') ``` 如果你想跨进程进到另一个程序中,你可以使用`Desktop`对象 ```python from subprocess import Popen from pywinauto import Desktop Popen('calc.exe', shell=True) dlg = Desktop(backend="uia").Calculator dlg.wait('visible') ``` 应用程序和桌面对象都是`backend`特定的,因此无需再使用后台名称了。 ### 窗口规格 这高级`pywinauto GUI`的核心概念,你可以使用它来模数窗口或者控件的更多细节,无论它是否存在或者已经关闭。窗口规范还保留着有关匹配算法、搜索算法,这些信息将用于获取真实的窗口或者控件。 我们开始创建一个窗口规范: ```python >>> dlg_spec = app.window(title='Untitled - Notepad') # 在中文环境下 # dlg_spec = app.window(title='无标题 - 记事本') >>> dlg_spec >>> dlg_spec.wrapper_object() # 中文 ``` 通过`warpper_object()`方法可以执行实际窗口的查找,它返回真实的窗口或控件的包装器`ElementNotFoundError`,这个包装器可以通过发送动作或者检索数据来处理窗口控件。 但`python`可以隐藏`wrapper_object()`调用,简化代码,例如: ```python dlg_spec.wrapper_object().minimize() # while debugging dlg_spec.minimize() # in production # 两行代码完全等价 ``` 创建窗口还有更多的标准,下面是几个示例: ```python # can be multi-level app.window(title_re='.* - Notepad$').window(class_name='Edit') # can combine criteria dlg = Desktop(backend="uia").Calculator dlg.window(auto_id='num8Button', control_type='Button') ``` ###魔法解析属性 `Python`通过动态解析对象属性来简化窗口规范,但是属性名和变量名一样有相同规范:无空格,逗号和其他特殊符号。幸运的是,`pywinauto`使用”最佳匹配“算法来查看抵消错别字和小的变化。 ```python app.UntitledNotepad # is equivalent to app.window(best_match='UntitledNotepad') ``` `Unicode`字符和特殊符号的使用可以通过字典中的项目进行访问(尤其对于中文来说,找不到相应的控件就对其进行字典访问) ```python app['Untitled - Notepad'] # is the same as app.window(best_match='Untitled - Notepad') ``` ### 如何得到魔法属性名称 有几个原则,如何将“最佳匹配“到的金光闪闪的名称附加到控件上。所以如果窗口规范接近于其中一个名称,那你就能成功匹配。 1. 根据标题(窗口文字,名称):`app.Properties.OK.click()` 2. 按标题和控制类型:`app.Properties.OKButton.click()` 3. 通过控制类型和数量:`app.Properties.Button3.click()`(Button和Button1匹配相同按钮,button2匹配下一个按钮) 4. 通过左上角的标签和控件类型:`app.OpenDialog.FileNameEdit.set_text("")` 5. 按控件类型和项目文本:`app.Properties.TabControlSharing.select("General")` 通常这些所有匹配的名称并非都可以同时使用。要检查指定对话框的这些名称,可以使用`print_control_identifiers()`方法。可用的最佳匹配名显示为树中每个控件的Python列表。更详细的窗口规范也可以从方法输出中复制。 例如: `app.Properties.child_window(title="Contains:", auto_id="13087", control_type="Edit")` ```python from pywinauto.application import Application app = Application(backend="uia").start('notepad.exe') # 查到这个记事本的控件树 dlg_spec = app['无标题 - 记事本'] dlg_spec.print_control_identifiers() Dialog - '无标题 - 记事本' (L403, T241, R1203, B609) ['Dialog', '无标题 - 记事本Dialog', '无标题 - 记事本'] child_window(title="无标题 - 记事本", control_type="Window") | | Edit - '文本编辑器' (L411, T292, R1195, B601) | ['', 'Edit', '0', '1'] | child_window(title="文本编辑器", auto_id="15", control_type="Edit") | | | | ScrollBar - '垂直滚动条' (L1178, T292, R1195, B601) | | ['垂直滚动条', '垂直滚动条ScrollBar', 'ScrollBar'] | | child_window(title="垂直滚动条", auto_id="NonClientVerticalScrollBar", control_type="ScrollBar") | | | | | | Button - '上一行' (L1178, T292, R1195, B309) | | | ['Button', '上一行', '上一行Button', 'Button0', 'Button1'] | | | child_window(title="上一行", auto_id="UpButton", control_type="Button") | | | | | | Button - '下一行' (L1178, T584, R1195, B601) | | | ['Button2', '下一行Button', '下一行'] | | | child_window(title="下一行", auto_id="DownButton", control_type="Button") | | TitleBar - 'None' (L427, T244, R1195, B272) | ['2', 'TitleBar'] | | | | Menu - '系统' (L411, T249, R433, B271) | | ['Menu', '系统', '系统Menu', '系统0', '系统1', 'Menu0', 'Menu1'] | | child_window(title="系统", auto_id="MenuBar", control_type="MenuBar") | | | | | | MenuItem - '系统' (L411, T249, R433, B271) | | | ['系统2', '系统MenuItem', 'MenuItem', 'MenuItem0', 'MenuItem1'] | | | child_window(title="系统", control_type="MenuItem") | | | | Button - '最小化' (L1056, T242, R1103, B272) | | ['Button3', '最小化', '最小化Button'] | | child_window(title="最小化", control_type="Button") | | | | Button - '最大化' (L1103, T242, R1149, B272) | | ['Button4', '最大化Button', '最大化'] | | child_window(title="最大化", control_type="Button") | | | | Button - '关闭' (L1149, T242, R1196, B272) | | ['Button5', '关闭Button', '关闭'] | | child_window(title="关闭", control_type="Button") | | Menu - '应用程序' (L411, T272, R1195, B291) | ['应用程序', 'Menu2', '应用程序Menu'] | child_window(title="应用程序", auto_id="MenuBar", control_type="MenuBar") | | | | MenuItem - '文件(F)' (L411, T272, R463, B291) | | ['文件(F)MenuItem', '文件(F)', 'MenuItem2'] | | child_window(title="文件(F)", control_type="MenuItem") | | | | MenuItem - '编辑(E)' (L463, T272, R516, B291) | | ['编辑(E)MenuItem', '编辑(E)', 'MenuItem3'] | | child_window(title="编辑(E)", control_type="MenuItem") | | | | MenuItem - '格式(O)' (L516, T272, R572, B291) | | ['格式(O)MenuItem', '格式(O)', 'MenuItem4'] | | child_window(title="格式(O)", control_type="MenuItem") | | | | MenuItem - '查看(V)' (L572, T272, R626, B291) | | ['查看(V)', '查看(V)MenuItem', 'MenuItem5'] | | child_window(title="查看(V)", control_type="MenuItem") | | | | MenuItem - '帮助(H)' (L626, T272, R681, B291) | | ['帮助(H)', '帮助(H)MenuItem', 'MenuItem6'] | | child_window(title="帮助(H)", control_type="MenuItem") Process finished with exit code 0 ``` ### 一些例子 下面的这些例子所包括:注意:示例是依赖于语言的,他们仅适用于所coding的产品语言,如下所示例的均为英文环境。 - `mspaint.py` 控制`MSPaint` - `notepad_fast.py` 使用快速时间设置来控制笔记本 - `notepad_slow.py` 使用慢时间设置来控制笔记本 - `notepad_item.py` 使用项目,然后属性访问控件记事本。 - `misc_examples.py` 显示一些异常以及如何获取控制标识符。 - `save_from_internet_explorer.py` 从Internet Explorer保存网页。 - `save_from_firefox.py` 从Firefox保存网页。 - `get_winrar_info.py` 如何做多语言自动化的例子。这不是一个理想的例子(适用于法语,捷克语和德语WinRar) - `forte_agent_sample.py` 处理复杂的应用程序的例子是非常动态的,并且在启动时经常给出不同的对话框。 - `windowmediaplayer.py` 另一个例子 - 处理ListView中的复选框。 - `test_sakura.py`,`test_sakura2.py` 自动化一个Japanase产品的两个例子。 ### 在命令行自动化记事本 请按照如下示例运行 ```python from pywinauto.application import Application import time app = Application().start('notepad.exe') time.sleep(1) app[' 无标题 - 记事本 '].menu_select("编辑(&E) -> 替换(&R)..") time.sleep(1) app['替换'].取消.click() # 没有with_spaces 参数空格将不会被键入。请参阅SendKeys的这个方法的文档,因为它是SendKeys周围的薄包装。 app[' 无标题 - 记事本 '].Edit.type_keys("Hi from Python interactive prompt %s" % str(dir()), with_spaces = True) app[' 无标题 - 记事本 '].menu_select('文件(&F) -> 退出(&X)') # 在这时候不清楚“不保存”的按钮名就对app['记事本'] 使用print_control_identifiers() app['记事本'].Button2.click() ```