Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Pywinauto Readthedocs Io en Stable

Download as pdf or txt
Download as pdf or txt
You are on page 1of 165

pywinauto Documentation

Release 0.6.8

The pywinauto contributors community

Dec 18, 2019


Contents

1 What is pywinauto 1
1.1 What is it? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Manual installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.4 How does it work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.5 Some similar tools for comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.6 Why write yet another automation tool if there are so many out there? . . . . . . . . . . . . . . . . . 3

2 Getting Started Guide 5


2.1 GUI Objects Inspection / Spy Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Entry Points for Automation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Window Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 Attribute Resolution Magic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.5 How to know magic attribute names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.6 How to disable magic attribute names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.7 Look at the examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.8 Automate notepad at the command line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3 How To’s 13
3.1 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 How to specify a usable Application instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3 How to specify a dialog of the application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4 How to specify a control on a dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.5 How to use pywinauto with application languages other than English . . . . . . . . . . . . . . . . . 17
3.6 How to deal with controls that do not respond as expected (e.g. OwnerDraw Controls) . . . . . . . . 17
3.7 How to Access the System Tray (aka SysTray, aka ‘Notification Area’) . . . . . . . . . . . . . . . . 18
3.8 COM Threading Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4 Waiting for Long Operations 21


4.1 Application methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.2 WindowSpecification methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.3 Functions in timings module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.4 Global timings for all actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.5 Identify controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

5 Remote Execution Guide 23


5.1 Windows Remote Desktop features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.2 VNC Server software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

i
5.3 Other remote access software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.4 Tricks to run automation on a locked machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.5 Start remote script using agent based CI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.6 Start remote script directly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

6 Methods available to each different control type 27


6.1 All Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.2 Button, CheckBox, RadioButton, GroupBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
6.3 ComboBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
6.4 Dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
6.5 Edit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
6.6 Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
6.7 ListBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
6.8 ListView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
6.9 PopupMenu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.10 ReBar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.11 Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.12 StatusBar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.13 TabControl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.14 Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.15 ToolTips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.16 TreeView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.17 UpDown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

7 Credits 35

8 Dev Notes 37
8.1 FILE LAYOUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
8.2 Best matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
8.3 ATTRIBUTE RESOLUTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
8.4 WRITING TO DIALOGS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

9 PYWINAUTO TODO’s 41
9.1 CLOSED (in some way or the other) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

10 Change Log 45
10.1 0.6.8 Bug Fixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
10.2 0.6.7 Bug Fixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
10.3 0.6.6 Better WinForms/Qt5 Support, Bug Fixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
10.4 0.6.5 Handling Privileges, AutomationID for Win32 etc. . . . . . . . . . . . . . . . . . . . . . . . . 46
10.5 0.6.4 NULL pointer access fix and enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
10.6 0.6.3 A lot of improvements and some optimizations . . . . . . . . . . . . . . . . . . . . . . . . . . 47
10.7 0.6.2 More bug fixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
10.8 0.6.1 Bug fixes and optimizations for UI Automation and beyond . . . . . . . . . . . . . . . . . . . 49
10.9 0.6.0 Introduce MS UI Automation support and many more improvements . . . . . . . . . . . . . . 50
10.10 0.5.4 Bug fixes and partial MFC Menu Bar support . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
10.11 0.5.3 Better Unicode support for SetEditText/TypeKeys and menu items . . . . . . . . . . . . . . . . 50
10.12 0.5.2 Improve ListView, new methods for CPU usage, DPI awareness . . . . . . . . . . . . . . . . . 51
10.13 0.5.1 Several fixes, more tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
10.14 0.5.0 64-bit Py2/Py3 compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
10.15 0.4.0 Various cleanup and bug fixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
10.16 0.3.9 Experimental! New Sendkeys, and various fixes . . . . . . . . . . . . . . . . . . . . . . . . . 53
10.17 0.3.8 Collecting improvements from last 2 years . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
10.18 0.3.7 Merge of Wait changes and various bug fixes/improvements . . . . . . . . . . . . . . . . . . . 54
10.19 0.3.6b Changes not documented in 0.3.6 history . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

ii
10.20 0.3.6 Scrolling and Treview Item Clicking added . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
10.21 0.3.5 Moved to Metaclass control wrapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
10.22 0.3.4 Fixed issue with latest ctypes, speed gains, other changes . . . . . . . . . . . . . . . . . . . . . 56
10.23 0.3.3 Added some methods, and fixed some small bugs . . . . . . . . . . . . . . . . . . . . . . . . . 56
10.24 0.3.2 Fixed setup.py and some typos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
10.25 0.3.1 Performance tune-ups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
10.26 0.3.0 Added Application data - now useful for localization testing . . . . . . . . . . . . . . . . . . . 57
10.27 0.2.5 More refactoring, more tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
10.28 0.2.1 Small Release number - big changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
10.29 0.2.0 Significant refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
10.30 0.1.3 Many changes, few visible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
10.31 0.1.2 Add Readme and rollup various changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
10.32 0.1.1 Minor bug fix release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
10.33 0.1.0 Initial Release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

11 Source code reference 63


11.1 Basic User Input Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
11.2 Main User Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
11.3 Specific Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
11.4 Controls Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
11.5 Pre-supplied Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
11.6 Backend Internal Implementation modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
11.7 Internal Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

12 Indices and tables 135

Python Module Index 137

iii
iv
CHAPTER 1

What is pywinauto

© Mark Mc Mahon and Contributors (https://github.com/pywinauto/pywinauto/graphs/contributors), 2006-2018


Released under the BSD 3-clause license

1.1 What is it?

pywinauto is a set of python modules to automate the Microsoft Windows GUI. At it’s simplest it allows you to send
mouse and keyboard actions to windows dialogs and controls.

1.2 Installation
• Just run pip install pywinauto

1.3 Manual installation

• Install the following Python packages


– pyWin32 (https://github.com/mhammond/pywin32/releases)
– comtypes (https://github.com/enthought/comtypes/releases)
– six (https://pypi.python.org/pypi/six)
– (optional) Pillow (https://pypi.python.org/pypi/Pillow/2.7.0) (to make screenshoots)
• Download latest pywinauto from https://github.com/pywinauto/pywinauto/releases
• Unpack and run python setup.py install
To check you have it installed correctly Run Python
>>> from pywinauto.application import Application
>>> app = Application(backend="uia").start("notepad.exe")
>>> app.UntitledNotepad.type_keys("%FX")

1
pywinauto Documentation, Release 0.6.8

1.4 How does it work

The core concept is described in the Getting Started Guide.


A lot is done through attribute access (__getattribute__) for each class. For example when you get the attribute
of an Application or Dialog object it looks for a dialog or control (respectively).
myapp.Notepad # looks for a Window/Dialog of your app that has a title 'similar'
# to "Notepad"

myapp.PageSetup.OK # looks first for a dialog with a title like "PageSetup"


# then it looks for a control on that dialog with a title
# like "OK"

This attribute resolution is delayed (with a default timeout) until it succeeds. So for example if you select a menu
option and then look for the resulting dialog e.g.
app.UntitledNotepad.menu_select("File->SaveAs")
app.SaveAs.ComboBox5.select("UTF-8")
app.SaveAs.edit1.set_text("Example-utf8.txt")
app.SaveAs.Save.click()

At the 2nd line the SaveAs dialog might not be open by the time this line is executed. So what happens is that we
wait until we have a control to resolve before resolving the dialog. At that point if we can’t find a SaveAs dialog with
a ComboBox5 control then we wait a very short period of time and try again, this is repeated up to a maximum time
(currently 5 seconds!)
This is to avoid having to use time.sleep or a “wait” function explicitly.
If your application performs long time operation, new dialog can appear or disappear later. You can wait for its new
state like so
app.Open.Open.click() # opening large file
app.Open.wait_not('visible') # make sure "Open" dialog became invisible
# wait for up to 30 seconds until data.txt is loaded
app.window(title='data.txt - Notepad').wait('ready', timeout=30)

1.5 Some similar tools for comparison

• Python tools
– PyAutoGui (https://github.com/asweigart/pyautogui) - a popular cross-platform library (has image-based
search, no text-based controls manipulation).
– Lackey (https://github.com/glitchassassin/lackey) - a pure Python replacement for Sikuli (based on image
pattern matching).
– AXUI (https://github.com/xcgspring/AXUI) - one of the wrappers around MS UI Automation API.
– winGuiAuto (https://github.com/arkottke/winguiauto) - another module using Win32 API.
• Other scripting language tools
– (Perl) Win32::GuiTest (http://winguitest.sourceforge.net/)
– (Ruby) Win32-Autogui (https://github.com/robertwahler/win32-autogui) - a wrapper around Win32 API.
– (Ruby) RAutomation (https://github.com/jarmo/RAutomation) - there are 3 adapters: Win32 API, UIA,
AutoIt.

2 Chapter 1. What is pywinauto


pywinauto Documentation, Release 0.6.8

• Other free tools


– (C#) Winium.Desktop (https://github.com/2gis/Winium.Desktop) - a young but good MS UI Automation
based tool.
– (C#) TestStack.White (https://github.com/TestStack/White) - another good MS UI Automation based li-
brary with a long history.
– AutoIt (http://www.autoitscript.com/) - free tool with its own Basic-like language (Win32 API based, no
.NET plans)
– AutoHotKey (https://github.com/Lexikos/AutoHotkey_L/) - native C++ tool with its own scripting lan-
guage (.ahk)
– “Awesome test automation” list (https://github.com/atinfo/awesome-test-automation) on GitHub
– A big list of open source tools for functional testing (http://www.opensourcetesting.org/category/functional/)
• Commercial tools
– WinRunner (http://www.mercury.com/us/products/quality-center/functional-testing/winrunner/)
– SilkTest (http://www.segue.com/products/functional-regressional-testing/silktest.asp)
– Many Others (http://www.testingfaqs.org/t-gui.html)

1.6 Why write yet another automation tool if there are so many out
there?

There are loads of reasons :-)


Takes a different approach: Most other tools are not object oriented you end up writing stuff like:
window = findwindow(title = "Untitled - Notepad", class = "Notepad")
SendKeys(window, "%OF") # Format -> Font
fontdialog = findwindow("title = "Font")
buttonClick(fontdialog, "OK")

I was hoping to create something more userfriendly (and pythonic). For example the translation of above would
be:
win = app.UntitledNotepad
win.menu_select("Format->Font")
app.Font.OK.click()

Python makes it easy: Python is a great programming language, but there are no automation tools that were Pythonic
(the very few libraries were implemented in Python).
Localization as a main requirement: Mark:
“I work in the localization industry and GUI automation is used extensively as often all you need to do is ensure
that your UI behaves and is correct with respect to the Source UI. This is actually an easier job then for testing
the original source UI.
But most automation tools are based off of coordinates or text of the controls and these can change in the
localized software. So my goal ( though not yet implemented) is to allow scripts to run unchanged between
original source language (often English) and the translated software (Japanese, German, etc).”

1.6. Why write yet another automation tool if there are so many out there? 3
pywinauto Documentation, Release 0.6.8

4 Chapter 1. What is pywinauto


CHAPTER 2

Getting Started Guide

Once you have installed pywinauto - how do you get going? The very first necessary thing is to determine which
accessibility technology (pywinauto’s backend) could be used for your application.
The list of supported accessibility technologies on Windows:
• Win32 API (backend="win32") - a default backend for now
– MFC, VB6, VCL, simple WinForms controls and most of the old legacy apps
• MS UI Automation (backend="uia")
– WinForms, WPF, Store apps, Qt5, browsers
Notes: Chrome requires --force-renderer-accessibility cmd flag before starting. Custom
properties and controls are not supported because of comtypes Python library restrictions.
AT SPI on Linux and Apple Accessibility API are in the long term plans so far.

2.1 GUI Objects Inspection / Spy Tools

If you’re still not sure which backend is most appropriate for you then try using object inspection / spy tools that
are available for free: download them from GitHub repo gui-inspect-tool (https://github.com/blackrosezy/gui-inspect-
tool).
• Spy++ is included into MS Visual Studio distribution (even Express or Community) and is accessible through
Start menu. It uses Win32 API. It means if Spy++ can show all the controls the "win32" backend is what you
need. AutoIt Window Info tool is a kind of Spy++ clone.
• Inspect.exe is another great tool created by Microsoft. It’s included into Windows SDK so that it can be found
in the following location on x64 Windows:
C:\Program Files (x86)\Windows Kits\<winver>\bin\x64

Switch Inspect.exe into UIA mode (using MS UI Automation). If it can show more controls and their properties
than Spy++, probably the "uia" backend is your choice.
• py_inspect (https://github.com/pywinauto/py_inspect) is a prototype of multi-backend spy tool based on py-
winauto. Switching between available backends can show you a difference in hierarchies with “win32” and
“uia” backends. py_inspect is a future replacement of SWAPY (https://github.com/pywinauto/SWAPY) which
supports “win32” backend only at the moment when pywinauto==0.5.4 was out. Initial implementation of
py_inspect contains just about 150 lines of code thanks to modern pywinauto 0.6.0+ architecture.
If some or all controls are not visible to all the inspection tools it’s still possible to control the application by generating
mouse and keyboard events using basic modules mouse and keyboard.

5
pywinauto Documentation, Release 0.6.8

2.2 Entry Points for Automation

So you have an application, you know it supports one of the mentioned accessibility technologies. What’s the next?
First you should start your application or connect to an existing app instance. It can be done with an Application
object. This is not just a clone of subprocess.Popen, but an entry point for further automation limiting all the
scope by process boundaries. It’s useful to control potentially few instances of an application (you work with one
instance not bothering another ones).
from pywinauto.application import Application
app = Application(backend="uia").start('notepad.exe')

# describe the window inside Notepad.exe process


dlg_spec = app.UntitledNotepad
# wait till the window is really open
actionable_dlg = dlg_spec.wait('visible')

If you want to navigate across process boundaries (say Win10 Calculator surprisingly draws its widgets in more than
one process) your entry point is a Desktop object.
from subprocess import Popen
from pywinauto import Desktop

Popen('calc.exe', shell=True)
dlg = Desktop(backend="uia").Calculator
dlg.wait('visible')

Application and Desktop objects are both backend-specific. No need to use backend name in further actions explicitly.

2.3 Window Specification

It’s a core concept for the high level pywinauto API. You are able to describe any window or control approximately
or in more details even if it doesn’t exist yet or already closed. Window specification also keeps information about
matching/search algorithm that will be used to get a real window or control.
Let’s create a detailed window specification:
>>> dlg_spec = app.window(title='Untitled - Notepad')

>>> dlg_spec
<pywinauto.application.WindowSpecification object at 0x0568B790>

>>> dlg_spec.wrapper_object()
<pywinauto.controls.win32_controls.DialogWrapper object at 0x05639B70>

Actual window lookup is performed by wrapper_object() method. It returns some wrapper for the real existing
window/control or raises ElementNotFoundError. This wrapper can deal with the window/control by sending
actions or retrieving data.
But Python can hide this wrapper_object() call so that you have more compact code in production. The follow-
ing statements do absolutely the same:
dlg_spec.wrapper_object().minimize() # while debugging
dlg_spec.minimize() # in production

There are many possible criteria for creating window specifications. These are just a few examples.

6 Chapter 2. Getting Started Guide


pywinauto Documentation, Release 0.6.8

# 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')

The list of possible criteria can be found in the pywinauto.findwindows.find_elements() function.

2.4 Attribute Resolution Magic

Python simplifies creating window specification by resolving object attributes dynamically. But an attibute name has
the same limitations as any variable name: no spaces, commas and other special symbols. But fortunately pywinauto
uses “best match” algorithm to make a lookup resistant to typos and small variations.
app.UntitledNotepad
# is equivalent to
app.window(best_match='UntitledNotepad')

Unicode characters and special symbols usage is possible through an item access in a dictionary like manner.
app['Untitled - Notepad']
# is the same as
app.window(best_match='Untitled - Notepad')

2.5 How to know magic attribute names

There are several principles how “best match” gold names are attached to the controls. So if a window specification is
close to one of these names you will have a successful name matching.
1. By title (window text, name): app.Properties.OK.click()
2. By title and control type: app.Properties.OKButton.click()
3. By control type and number: app.Properties.Button3.click() (Note: Button0 and Button1 match
the same button, Button2 is the next etc.)
4. By top-left label and control type: app.OpenDialog.FileNameEdit.set_text("")
5. By control type and item text: app.Properties.TabControlSharing.select("General")
Often not all of these matching names are available simultaneously. To check these names for specified dia-
log you can use print_control_identifiers() method. Possible “best_match” names are displayed as
a Python list for every control in a tree. More detailed window specification can also be just copied from the
method output. Say app.Properties.child_window(title="Contains:", auto_id="13087",
control_type="Edit").
>>> app.Properties.print_control_identifiers()

Control Identifiers:

Dialog - 'Windows NT Properties' (L688, T518, R1065, B1006)


[u'Windows NT PropertiesDialog', u'Dialog', u'Windows NT Properties']
child_window(title="Windows NT Properties", control_type="Window")
|
| Image - '' (L717, T589, R749, B622)

2.4. Attribute Resolution Magic 7


pywinauto Documentation, Release 0.6.8

| [u'', u'0', u'Image1', u'Image0', 'Image', u'1']


| child_window(auto_id="13057", control_type="Image")
|
| Image - '' (L717, T630, R1035, B632)
| ['Image2', u'2']
| child_window(auto_id="13095", control_type="Image")
|
| Edit - 'Folder name:' (L790, T596, R1036, B619)
| [u'3', 'Edit', u'Edit1', u'Edit0']
| child_window(title="Folder name:", auto_id="13156", control_type="Edit")
|
| Static - 'Type:' (L717, T643, R780, B658)
| [u'Type:Static', u'Static', u'Static1', u'Static0', u'Type:']
| child_window(title="Type:", auto_id="13080", control_type="Text")
|
| Edit - 'Type:' (L790, T643, R1036, B666)
| [u'4', 'Edit2', u'Type:Edit']
| child_window(title="Type:", auto_id="13059", control_type="Edit")
|
| Static - 'Location:' (L717, T669, R780, B684)
| [u'Location:Static', u'Location:', u'Static2']
| child_window(title="Location:", auto_id="13089", control_type="Text")
|
| Edit - 'Location:' (L790, T669, R1036, B692)
| ['Edit3', u'Location:Edit', u'5']
| child_window(title="Location:", auto_id="13065", control_type="Edit")
|
| Static - 'Size:' (L717, T695, R780, B710)
| [u'Size:Static', u'Size:', u'Static3']
| child_window(title="Size:", auto_id="13081", control_type="Text")
|
| Edit - 'Size:' (L790, T695, R1036, B718)
| ['Edit4', u'6', u'Size:Edit']
| child_window(title="Size:", auto_id="13064", control_type="Edit")
|
| Static - 'Size on disk:' (L717, T721, R780, B736)
| [u'Size on disk:', u'Size on disk:Static', u'Static4']
| child_window(title="Size on disk:", auto_id="13107", control_type="Text")
|
| Edit - 'Size on disk:' (L790, T721, R1036, B744)
| ['Edit5', u'7', u'Size on disk:Edit']
| child_window(title="Size on disk:", auto_id="13106", control_type="Edit")
|
| Static - 'Contains:' (L717, T747, R780, B762)
| [u'Contains:1', u'Contains:0', u'Contains:Static', u'Static5', u'Contains:']
| child_window(title="Contains:", auto_id="13088", control_type="Text")
|
| Edit - 'Contains:' (L790, T747, R1036, B770)
| [u'8', 'Edit6', u'Contains:Edit']
| child_window(title="Contains:", auto_id="13087", control_type="Edit")
|
| Image - 'Contains:' (L717, T773, R1035, B775)
| [u'Contains:Image', 'Image3', u'Contains:2']
| child_window(title="Contains:", auto_id="13096", control_type="Image")
|
| Static - 'Created:' (L717, T786, R780, B801)
| [u'Created:', u'Created:Static', u'Static6', u'Created:1', u'Created:0']
| child_window(title="Created:", auto_id="13092", control_type="Text")

8 Chapter 2. Getting Started Guide


pywinauto Documentation, Release 0.6.8

|
| Edit - 'Created:' (L790, T786, R1036, B809)
| [u'Created:Edit', 'Edit7', u'9']
| child_window(title="Created:", auto_id="13072", control_type="Edit")
|
| Image - 'Created:' (L717, T812, R1035, B814)
| [u'Created:Image', 'Image4', u'Created:2']
| child_window(title="Created:", auto_id="13097", control_type="Image")
|
| Static - 'Attributes:' (L717, T825, R780, B840)
| [u'Attributes:Static', u'Static7', u'Attributes:']
| child_window(title="Attributes:", auto_id="13091", control_type="Text")
|
| CheckBox - 'Read-only (Only applies to files in folder)' (L790, T825, R1035, B841)
| [u'CheckBox0', u'CheckBox1', 'CheckBox', u'Read-only (Only applies to files in folder)Check
| child_window(title="Read-only (Only applies to files in folder)", auto_id="13075", control_
|
| CheckBox - 'Hidden' (L790, T848, R865, B864)
| ['CheckBox2', u'HiddenCheckBox', u'Hidden']
| child_window(title="Hidden", auto_id="13076", control_type="CheckBox")
|
| Button - 'Advanced...' (L930, T845, R1035, B868)
| [u'Advanced...', u'Advanced...Button', 'Button', u'Button1', u'Button0']
| child_window(title="Advanced...", auto_id="13154", control_type="Button")
|
| Button - 'OK' (L814, T968, R889, B991)
| ['Button2', u'OK', u'OKButton']
| child_window(title="OK", auto_id="1", control_type="Button")
|
| Button - 'Cancel' (L895, T968, R970, B991)
| ['Button3', u'CancelButton', u'Cancel']
| child_window(title="Cancel", auto_id="2", control_type="Button")
|
| Button - 'Apply' (L976, T968, R1051, B991)
| ['Button4', u'ApplyButton', u'Apply']
| child_window(title="Apply", auto_id="12321", control_type="Button")
|
| TabControl - '' (L702, T556, R1051, B962)
| [u'10', u'TabControlSharing', u'TabControlPrevious Versions', u'TabControlSecurity', u'TabC
| child_window(auto_id="12320", control_type="Tab")
| |
| | TabItem - 'General' (L704, T558, R753, B576)
| | [u'GeneralTabItem', 'TabItem', u'General', u'TabItem0', u'TabItem1']
| | child_window(title="General", control_type="TabItem")
| |
| | TabItem - 'Sharing' (L753, T558, R801, B576)
| | [u'Sharing', u'SharingTabItem', 'TabItem2']
| | child_window(title="Sharing", control_type="TabItem")
| |
| | TabItem - 'Security' (L801, T558, R851, B576)
| | [u'Security', 'TabItem3', u'SecurityTabItem']
| | child_window(title="Security", control_type="TabItem")
| |
| | TabItem - 'Previous Versions' (L851, T558, R947, B576)
| | [u'Previous VersionsTabItem', u'Previous Versions', 'TabItem4']
| | child_window(title="Previous Versions", control_type="TabItem")
| |
| | TabItem - 'Customize' (L947, T558, R1007, B576)

2.5. How to know magic attribute names 9


pywinauto Documentation, Release 0.6.8

| | [u'CustomizeTabItem', 'TabItem5', u'Customize']


| | child_window(title="Customize", control_type="TabItem")
|
| TitleBar - 'None' (L712, T521, R1057, B549)
| ['TitleBar', u'11']
| |
| | Menu - 'System' (L696, T526, R718, B548)
| | [u'System0', u'System', u'System1', u'Menu', u'SystemMenu']
| | child_window(title="System", auto_id="MenuBar", control_type="MenuBar")
| | |
| | | MenuItem - 'System' (L696, T526, R718, B548)
| | | [u'System2', u'MenuItem', u'SystemMenuItem']
| | | child_window(title="System", control_type="MenuItem")
| |
| | Button - 'Close' (L1024, T519, R1058, B549)
| | [u'CloseButton', u'Close', 'Button5']
| | child_window(title="Close", control_type="Button")

2.6 How to disable magic attribute names

In some cases, you might prefer disable the magic lookup system, so that Pywinauto immediately raises if you access
an attribute which exists neither on the WindowSpecification object, nor on the underlying element-wrapper object.
Indeed, by default, Pywinauto will add your attribute name to the search system, and will only fail on a subsequent
attribute access or method call.
In this case, turn off the allow_magic_lookup argument of your Desktop or Application instance:
desktop = Desktop(backend='win32', allow_magic_lookup=False)

or:
app = Application(allow_magic_lookup=False)

This flag will automatically be propagated to generated WindowSpecification objects.

2.7 Look at the examples

The following examples are included: Note: Examples are language dependent - they will only work on the language
of product that they were programmed for. All examples have been programmed for English Software except where
highlighted.
• mspaint.py Control MSPaint
• notepad_fast.py Use fast timing settings to control Notepad
• notepad_slow.py Use slow timing settings to control Notepad
• notepad_item.py Use item rather then attribute access to control Notepad.
• misc_examples.py Show some exceptions and how to get control identifiers.
• save_from_internet_explorer.py Save a Web Page from Internet Explorer.
• save_from_firefox.py Save a Web Page from Firefox.
• get_winrar_info.py Example of how to do multilingual automation. This is not an ideal example (works
on French, Czech and German WinRar)

10 Chapter 2. Getting Started Guide


pywinauto Documentation, Release 0.6.8

• forte_agent_sample.py Example of dealing with a complex application that is quite dynamic and gives
different dialogs often when starting.
• windowmediaplayer.py Just another example - deals with check boxes in a ListView.
• test_sakura.py, test_sakura2.py Two examples of automating a Japanase product.

2.8 Automate notepad at the command line

Please find below a sample run


C:\>python
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(1) >>> from pywinauto import application
(2) >>> app = application.Application()
(3) >>> app.start("Notepad.exe")
<pywinauto.application.Application object at 0x00AE0990>
(4) >>> app.UntitledNotepad.draw_outline()
(5) >>> app.UntitledNotepad.menu_select("Edit -> Replace")
(6) >>> app.Replace.print_control_identifiers()
Control Identifiers:

Dialog - 'Replace' (L179, T174, R657, B409)


['ReplaceDialog', 'Dialog', 'Replace']
child_window(title="Replace", class_name="#32770")
|
| Static - 'Fi&nd what:' (L196, T230, R292, B246)
| ['Fi&nd what:Static', 'Fi&nd what:', 'Static', 'Static0', 'Static1']
| child_window(title="Fi&nd what:", class_name="Static")
|
| Edit - '' (L296, T226, R524, B250)
| ['Fi&nd what:Edit', 'Edit', 'Edit0', 'Edit1']
| child_window(class_name="Edit")
|
| Static - 'Re&place with:' (L196, T264, R292, B280)
| ['Re&place with:', 'Re&place with:Static', 'Static2']
| child_window(title="Re&place with:", class_name="Static")
|
| Edit - '' (L296, T260, R524, B284)
| ['Edit2', 'Re&place with:Edit']
| child_window(class_name="Edit")
|
| CheckBox - 'Match &whole word only' (L198, T304, R406, B328)
| ['CheckBox', 'Match &whole word onlyCheckBox', 'Match &whole word only', 'CheckBox0', 'C
| child_window(title="Match &whole word only", class_name="Button")
|
| CheckBox - 'Match &case' (L198, T336, R316, B360)
| ['CheckBox2', 'Match &case', 'Match &caseCheckBox']
| child_window(title="Match &case", class_name="Button")
|
| Button - '&Find Next' (L536, T220, R636, B248)
| ['&Find Next', '&Find NextButton', 'Button', 'Button0', 'Button1']
| child_window(title="&Find Next", class_name="Button")
|
| Button - '&Replace' (L536, T254, R636, B282)
| ['&ReplaceButton', '&Replace', 'Button2']

2.8. Automate notepad at the command line 11


pywinauto Documentation, Release 0.6.8

| child_window(title="&Replace", class_name="Button")
|
| Button - 'Replace &All' (L536, T288, R636, B316)
| ['Replace &AllButton', 'Replace &All', 'Button3']
| child_window(title="Replace &All", class_name="Button")
|
| Button - 'Cancel' (L536, T322, R636, B350)
| ['CancelButton', 'Cancel', 'Button4']
| child_window(title="Cancel", class_name="Button")
|
| Button - '&Help' (L536, T362, R636, B390)
| ['&Help', '&HelpButton', 'Button5']
| child_window(title="&Help", class_name="Button")
|
| Static - '' (L196, T364, R198, B366)
| ['ReplaceStatic', 'Static3']
| child_window(class_name="Static")
(7) >>> app.Replace.Cancel.click()
(8) >>> app.UntitledNotepad.Edit.type_keys("Hi from Python interactive prompt %s" % str(dir()), wit
<pywinauto.controls.win32_controls.EditWrapper object at 0x00DDC2D0>
(9) >>> app.UntitledNotepad.menu_select("File -> Exit")
(10) >>> app.Notepad.DontSave.click()
>>>

1. Import the pywinauto.application module (usually the only module you need to import directly)
2. Create an Application instance. All access to the application is done through this object.
3. We have created an Application instance in step 2 but we did not supply any information on the Windows appli-
cation it referred to. By using the start() method we execute that application and connect it to the Application
instance app.
4. Draw a green rectangle around the Notepad dialog - so that we know we have the correct window.
5. Select the Replace item from the Edit Menu on the Notepad Dialog of the application that app is connected to.
This action will make the Replace dialog appear.
6. Print the identifiers for the controls on the Replace dialog, for example the 1st edit control on the Replace dialog
can be referred to by any of the following identifiers:
app.Replace.Edit
app.Replace.Edit0
app.Replace.Edit1
app.FindwhatEdit

The last is the one that gives the user reading the script aftewards the best idea of what the script does.
7. Close the Replace dialog. (In a script file it is safer to use close_click() rather than click() because close_click()
waits a little longer to give windows time to close the dialog.)
8. Let’s type some text into the Notepad text area. Without the with_spaces argument spaces would not be
typed. Please see documentation for SendKeys for this method as it is a thin wrapper around SendKeys.
9. Ask to exit Notepad
10. We will be asked if we want to save - click on the “No” button.

12 Chapter 2. Getting Started Guide


CHAPTER 3

How To’s

3.1 Definitions

Some important defitions may be helpful for beginners.


• Dialog is a window containing several other GUI elements/controls like buttons, edit boxes etc. Dialog is not
necessarily a main window. Message box on top of main form is also a dialog. Main form is also considered a
dialog by pywinauto.
• A control is GUI element at any level of a hierarchy. This definition includes window, button, edit box, grid,
grid cell, bar etc.
• Win32 API technology (“win32” backend in pywinauto) provides an identifier for every control. This is a unique
integer called handle.
• UI Automation API (“uia” backend in pywinauto) may not provide window handle for every GUI el-
ement. Such an element is not visible to “win32” backend. But Inspect.exe can show property
NativeWindowHandle if it’s available.

3.2 How to specify a usable Application instance

An Application() instance is the point of contact for all work with the application you are automating. So the
Application instance needs to be connected to a process. There are two ways of doing this:
start(self, cmd_line, timeout=app_start_timeout) # instance method:

or:
connect(self, **kwargs) # instance method:

start() is used when the application is not running and you need to start it. Use it in the following way:
app = Application().start(r"c:\path\to\your\application -a -n -y --arguments")

The timeout parameter is optional, it should only be necessary to use if the application takes a long time to start up.
connect() is used when the application to be automated is already launched. To specify an already running appli-
cation you need to specify one of the following:
process the process id of the application, e.g.
app = Application().connect(process=2341)

13
pywinauto Documentation, Release 0.6.8

handle The windows handle of a window of the application, e.g.


app = Application().connect(handle=0x010f0c)

path The path of the executable of the process (GetModuleFileNameEx is used to find the path of
each process and compared against the value passed in) e.g.
app = Application().connect(path=r"c:\windows\system32\notepad.exe")

or any combination of the parameters that specify a window, these get passed to the
pywinauto.findwindows.find_elements() function. e.g.
app = Application().connect(title_re=".*Notepad", class_name="Notepad")

Note: The application has to be ready before you can use connect*(). There is no timeout or retries like there is when
finding the application after start(). So if you start the application outside of pywinauto you need to either sleep or
program a wait loop to wait until the application has fully started.

3.3 How to specify a dialog of the application

Once the application instance knows what application it is connected to a dialog to work on needs to be specified.
There are many different ways of doing this. The most common will be using item or attribute access to select a dialog
based on it’s title. e.g
dlg = app.Notepad

or equivalently
dlg = app['Notepad']

The next easiest method is to ask for the top_window() e.g.


dlg = app.top_window()

This will return the window that has the highest Z-Order of the top-level windows of the application.
Note: This is currently fairly untested so I am not sure it will return the correct window. It will definitely be a top level
window of the application - it just might not be the one highest in the Z-Order.
If this is not enough control then you can use the same parameters as can be passed to
findwindows.find_windows() e.g.
dlg = app.window(title_re="Page Setup", class_name="#32770")

Finally to have the most control you can use


dialogs = app.windows()

this will return a list of all the visible, enabled, top level windows of the application. You can then use some of the
methods in handleprops module select the dialog you want. Once you have the handle you need then use
app.window(handle=win)

Note: If the title of the dialog is very long - then attribute access might be very long to type, in those cases it is usually
easier to use
app.window(title_re=".*Part of Title.*")

14 Chapter 3. How To’s


pywinauto Documentation, Release 0.6.8

3.4 How to specify a control on a dialog

There are a number of ways to specify a control, the simplest are


app.dlg.control
app['dlg']['control']

The 2nd is better for non English OS’s where you need to pass unicode strings e.g. app[u’your dlg
title’][u’your ctrl title’]
The code builds up multiple identifiers for each control from the following:
• title
• friendly class
• title + friendly class
If the control’s title text is empty (after removing non char characters) this text is not used. Instead we look for the
closest title text above and to the right of the control. And append the friendly class. So the list becomes
• friendly class
• closest text + friendly class
Once a set of identifiers has been created for all controls in the dialog we disambiguate them.
use the WindowSpecification.print_control_identifiers() method
e.g.
app.YourDialog.print_control_identifiers()

Sample output
Button - Paper (L1075, T394, R1411, B485)
'PaperGroupBox' 'Paper' 'GroupBox'
Static - Si&ze: (L1087, T420, R1141, B433)
'SizeStatic' 'Static' 'Size'
ComboBox - (L1159, T418, R1399, B439)
'ComboBox' 'SizeComboBox'
Static - &Source: (L1087, T454, R1141, B467)
'Source' 'Static' 'SourceStatic'
ComboBox - (L1159, T449, R1399, B470)
'ComboBox' 'SourceComboBox'
Button - Orientation (L1075, T493, R1171, B584)
'GroupBox' 'Orientation' 'OrientationGroupBox'
Button - P&ortrait (L1087, T514, R1165, B534)
'Portrait' 'RadioButton' 'PortraitRadioButton'
Button - L&andscape (L1087, T548, R1165, B568)
'RadioButton' 'LandscapeRadioButton' 'Landscape'
Button - Margins (inches) (L1183, T493, R1411, B584)
'Marginsinches' 'MarginsinchesGroupBox' 'GroupBox'
Static - &Left: (L1195, T519, R1243, B532)
'LeftStatic' 'Static' 'Left'
Edit - (L1243, T514, R1285, B534)
'Edit' 'LeftEdit'
Static - &Right: (L1309, T519, R1357, B532)
'Right' 'Static' 'RightStatic'
Edit - (L1357, T514, R1399, B534)
'Edit' 'RightEdit'
Static - &Top: (L1195, T550, R1243, B563)

3.4. How to specify a control on a dialog 15


pywinauto Documentation, Release 0.6.8

'Top' 'Static' 'TopStatic'


Edit - (L1243, T548, R1285, B568)
'Edit' 'TopEdit'
Static - &Bottom: (L1309, T550, R1357, B563)
'BottomStatic' 'Static' 'Bottom'
Edit - (L1357, T548, R1399, B568)
'Edit' 'BottomEdit'
Static - &Header: (L1075, T600, R1119, B613)
'Header' 'Static' 'HeaderStatic'
Edit - (L1147, T599, R1408, B619)
'Edit' 'TopEdit'
Static - &Footer: (L1075, T631, R1119, B644)
'FooterStatic' 'Static' 'Footer'
Edit - (L1147, T630, R1408, B650)
'Edit' 'FooterEdit'
Button - OK (L1348, T664, R1423, B687)
'Button' 'OK' 'OKButton'
Button - Cancel (L1429, T664, R1504, B687)
'Cancel' 'Button' 'CancelButton'
Button - &Printer... (L1510, T664, R1585, B687)
'Button' 'Printer' 'PrinterButton'
Button - Preview (L1423, T394, R1585, B651)
'Preview' 'GroupBox' 'PreviewGroupBox'
Static - (L1458, T456, R1549, B586)
'PreviewStatic' 'Static'
Static - (L1549, T464, R1557, B594)
'PreviewStatic' 'Static'
Static - (L1466, T586, R1557, B594)
'Static' 'BottomStatic'

This example has been taken from test_application.py


Note The identifiers printed by this method have been run through the process that makes the identifier unique. So
if you have two edit boxes, they will both have “Edit” listed in their identifiers. In reality though the first one can be
refered to as “Edit”, “Edit0”, “Edit1” and the 2nd should be refered to as “Edit2”
Note You do not have to be exact!. Say we take an instance from the example above
Button - Margins (inches) (L1183, T493, R1411, B584)
'Marginsinches' 'MarginsinchesGroupBox' 'GroupBox'

Let’s say that you don’t like any of these


• GroupBox - too generic, it could be any group box
• Marginsinches and MarginsinchesGroupBox - these just don’ look right, it would be nicer to leave
out the ‘inches’ part
Well you CAN! The code does a best match on the identifer you use against all the available identifiers in the dialog.
For example if you break into the debugger you can see how different identifiers can be used
(Pdb) print app.PageSetup.Margins.window_text()
Margins (inches)
(Pdb) print app.PageSetup.MarginsGroupBox.window_text()
Margins (inches)

And this will also cater for typos. Though you still have to be careful as if there are 2 similar identifiers in the dialog
the typo you have used might be more similar to another control than the one you were thinking of.

16 Chapter 3. How To’s


pywinauto Documentation, Release 0.6.8

3.5 How to use pywinauto with application languages other than En-
glish

Because Python does not support unicode identifiers in code you cannot use attribute access to reference a control so
you would either have to use item access or make an explicit calls to window().
So instead of writing
app.dialog_ident.control_ident.click()

You would have to write


app['dialog_ident']['control_ident'].click()

Or use window() explictly


app.window(title_re="NonAsciiCharacters").window(title="MoreNonAsciiCharacters").click()

To see an example of this check examples\misc_examples.py get_info()

3.6 How to deal with controls that do not respond as expected (e.g.
OwnerDraw Controls)

Some controls (especially Ownerdrawn controls) do not respond to events as expected. For example if you look at any
HLP file and go to the Index Tab (click ‘Search’ button) you will see a listbox. Running Spy or Winspector on this
will show you that it is indeed a list box - but it is ownerdrawn. This means that the developer has told Windows that
they will override how items are displayed and do it themselves. And in this case they have made it so that strings
cannot be retrieved :-(.
So what problems does this cause?
app.HelpTopics.ListBox.texts() # 1
app.HelpTopics.ListBox.select("ItemInList") # 2

1. Will return a list of empty strings, all this means is that pywinauto has not been able to get the strings in the
listbox
2. This will fail with an IndexError because the select(string) method of a ListBox looks for the item in the Texts
to know the index of the item that it should select.
The following workaround will work on this control
app.HelpTopics.ListBox.select(1)

This will select the 2nd item in the listbox, because it is not a string lookup it works correctly.
Unfortunately not even this will always work. The developer can make it so that the control does not respond to
standard events like Select. In this case the only way you can select items in the listbox is by using the keyboard
simulation of TypeKeys().
This allows you to send any keystrokes to a control. So to select the 3rd item you would use
app.Helptopics.ListBox1.type_keys("{HOME}{DOWN 2}{ENTER}")

• {HOME} will make sure that the first item is highlighted.


• {DOWN 2} will then move the highlight down two items

3.5. How to use pywinauto with application languages other than English 17
pywinauto Documentation, Release 0.6.8

• {ENTER} will select the highlighted item


If your application made an extensive use of a similar control type then you could make using it easier by deriving a
new class from ListBox, that could use extra knowledge about your particular application. For example in the WinHelp
example every time an item is highlighted in the list view, its text is inserted into the Edit control above the list, and
you CAN get the text of the item from there e.g.
# print the text of the item currently selected in the list box
# (as long as you are not typing into the Edit control!)
print app.HelpTopics.Edit.texts()[1]

3.7 How to Access the System Tray (aka SysTray, aka ‘Notification
Area’)

Near the clock there are icons representing running applications, this area is normally referred to as the “System Tray”.
In fact, there are many different windows/controls in this area. The control that contains the icons is actually a toolbar.
It is a child of Pager control within a window with a class TrayNotifyWnd, which is inside another window with a
class Shell_TrayWnd and all these windows are part of the running Explorer instance. Thankfully you don’t need to
remember all that :-).
The thing that is important to remember is that you are looking for a window in the “Explorer.exe” application with
the class “Shell_TrayWnd” that has Toolbar control with a title “Notification Area”.
One way to get this is to do the following
import pywinauto.application
app = pywinauto.application.Application().connect(path="explorer")
systray_icons = app.ShellTrayWnd.NotificationAreaToolbar

The taskbar module provides very preliminary access to the System Tray.
It defines the following variables:
explorer_app defines an Application() object connected to the running explorer. You probably don’t
need to use it directly very much.
TaskBar The handle to the task bar (the bar containing Start Button, the QuickLaunch icons, running
tasks, etc
StartButton “Start me up” :-) I think you might know what this is!
QuickLaunch The Toolbar with the quick launch icons
SystemTray The window that contains the Clock and System Tray Icons
Clock The clock
SystemTrayIcons The toolbar representing the system tray icons
RunningApplications The toolbar representing the running applications
I have also provided two functions in the module that can be used to click on system tray icons:
ClickSystemTrayIcon(button) You can use this to left click a visible icon in the system tray.
I had to specifically say visible icon as there may be many invisible icons that obviously cannot
be clicked. Button can be any integer. If you specify 3 then it will find and click the 3rd visible
button. (Almost no error checking is performed now here but this method will more than likely be
moved/renamed in the future.)

18 Chapter 3. How To’s


pywinauto Documentation, Release 0.6.8

RightClickSystemTrayIcon(button) Similar to ClickSytemTrayIcon but performs a


right click.
Often, when you click/right click on an icon, you get a popup menu. The thing to remember at this point is that the
popup menu is a part of the application being automated not part of explorer.
e.g.
# 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()

3.8 COM Threading Model

By default, pywinauto sets up the client Multithreading COM model (MTA) on init if no other model was defined
prior to import of pywinauto. The model can be set up by another imported module implicitly or specified explicitly
through sys.coinit_flags.
Example for overriding MTA by setting the single threaded appartment model explicitly.
import sys
sys.coinit_flags = 2 # COINIT_APARTMENTTHREADED

import pywinauto

Notice that the final value of COM model is assigned back to sys.coinit_flags. This is to avoid conflicts with
other modules. Possible values for sys.coinit_flags:
• 0 - Multi-Threaded Apartment model (MTA)
• 2 - Single-Threaded Apartment model (STA)
More info:
• About Microsoft COM threading models: Understanding and Using COM Threading Models
(https://msdn.microsoft.com/en-us/library/ms809971.aspx)
• Internal discussion (https://github.com/pywinauto/pywinauto/issues/394#issuecomment-334926345) on pywin-
auto MTA.

3.8. COM Threading Model 19


pywinauto Documentation, Release 0.6.8

20 Chapter 3. How To’s


CHAPTER 4

Waiting for Long Operations

A GUI application behaviour is often unstable and your script needs waiting until a new window appears or an existing
window is closed/hidden. pywinauto can flexibly wait for a dialog initialization implicitly (with the default timeout)
or explicitly using dedicated methods/functions that could help you to make your code easier and more reliable.

4.1 Application methods

• wait_cpu_usage_lower (new in pywinauto 0.5.2, renamed in 0.6.0)


This method is useful for multi-threaded interfaces that allow a lazy initialization in another thread while GUI is
responsive and all controls already exist and seems ready to use. So waiting for a specific window existence/state is
useless. In such case the CPU usage for the whole process indicates that a task calculation is not finished yet.
Example:
app.wait_cpu_usage_lower(threshold=5) # wait until CPU usage is lower than 5%

NOTE: this method is available for the whole application process only, not for a window/element.

4.2 WindowSpecification methods

These methods are available to all controls.


• wait
• wait_not
There is an example containing long waits: install script for 7zip 9.20 x64 (https://gist.github.com/vasily-v-
ryabov/7a04717af4584cbb840f).
A WindowSpecification object isn’t necessarily related to an existing window/control. It’s just a description
namely a couple of criteria to search the window. The wait method (if no any exception is raised) can guarantee that
the target control exists or even visible, enabled and/or active.

4.3 Functions in timings module

There are also low-level methods useful for any Python code.
• wait_until

21
pywinauto Documentation, Release 0.6.8

• wait_until_passes
Decorators pywinauto.timings.always_wait_until() and pywinauto.timings.always_wait_until_passes(
can also be used if every function call should have timing control.
# call ensure_text_changed(ctrl) every 2 sec until it's passed or timeout (4 sec) is expired

@always_wait_until_passes(4, 2)
def ensure_text_changed(ctrl):
if previous_text == ctrl.window_text():
raise ValueError('The ctrl text remains the same while change is expected')

4.4 Global timings for all actions

Many actions require some pause before, after and in-between. There are several global constants in module timings
defining such pauses. It can be aligned for your needs individually by setting global static variables in object
timings.Timings.
All global timings can be set to default at once, or doubled, or divided by two:
from timings import Timings

Timings.defaults()
Timings.slow() # double all timings (~2x slower script execution)
Timings.fast() # divide all timings by two (~2x faster)

4.5 Identify controls

The methods to help you to find a needed control.


• print_control_identifiers
• draw_outline

4.5.1 How To‘s

• How To’s

22 Chapter 4. Waiting for Long Operations


CHAPTER 5

Remote Execution Guide

Desktop GUI tests usually require active desktop to move mouse cursor and type some keys into a focused window.
That completely blocks local machine from normal usage.
But running tests on a remote machine is a challenge. This guide collected known issues and solutions to control a
remote machine with GUI tests.

5.1 Windows Remote Desktop features

Remote Desktop (RDP) provides virtual active desktop to remote machine with Windows OS. There are 2 potential
issues:
• If RDP window is minimized, there is no active desktop on remote PC by default.
• If RDP is disconnected, the desktop is locked out.
In both cases any GUI automation jobs will fail (if you don’t use some tricks described below). The workarounds are
well described in TestComplete documetation:
• Running Tests in Minimized Remote Desktop Windows (https://support.smartbear.com/testcomplete/docs/testing-
with/running/via-rdp/in-minimized-window.html)
• Disconnecting From Remote Desktop While Running Automated Tests
(https://support.smartbear.com/testcomplete/docs/testing-with/running/via-rdp/keeping-computer-
unlocked.html)

5.2 VNC Server software

There is more simple way to avoid above issues: using VNC server software (for example, Tight VNC). It works as a
pair of client and server. VNC server also provides active desktop on a remote machine.
• This is a non-virtual desktop so working with native screen resolution on a remote PC may require updating
video drivers.
• Minimizing or disconnecting VNC client doesn’t destroy active desktop (by default!).
• This is a cross-platform solution (VNC server is a native part of macOS and available on Linux).
The only problem you may face with:
• Using Remote Desktop (RDP) may break VNC server benefits and you have to restart remote PC or apply RDP
workarounds described above.

23
pywinauto Documentation, Release 0.6.8

5.3 Other remote access software

If anyone tried to run GUI tests/automation remotely using Team Viewer, PowerBI desktop or any other virtual desktop
software, feel free to add more details into this guide.

5.4 Tricks to run automation on a locked machine

For some applications it’s possible to run GUI automation on a locked machine, but it requires using special methods.
First it’s worth listing methods that don’t work on a locked machine:
• click_input and all other mouse click and press methods ending with _input.
• set_focus as it uses SetCursorPos and SetForegroundWindow.
• type_keys for native keyboard input.
• Direct usage of modules mouse and keyboard.
Some other methods may not work also, but it depends on application. There are few methods for silent text input in
backend="win32":
• send_chars (symbols only; special key combinations do not work)
• send_keystrokes (some special key combinations may work)
There is another useful method to enter string at once (available for both backends, usually for edit box only):
• “uia”: set_edit_text (enter text as is, no modifiers supported)
• “win32”: set_edit_text

5.5 Start remote script using agent based CI

When your script is ready and you can run it on a remote machine manually, it’s time to automate the last step: trigger
running the script from local machine or from CI server.
If you have internal hosted CI (for example, Jenkins), probably target machine is already connected to Jenkins master
using an agent. There are three ways to connect agent:
• Run agent as a service: GUI tests won’t work in this case because GUI can’t be even created when running as a
service.
• Run agent through SSH: GUI tests won’t work.
• Run agent as a normal application. This is the only working case!

5.6 Start remote script directly

This chapter is inspired by issue #401 (https://github.com/pywinauto/pywinauto/issues/401) (special thanks to yan-


gliang003 (https://github.com/yangliang003)).
First option is PsExec. Thanks to this post on StackExchange (https://serverfault.com/a/852877/368634).
1. Download PsTools (https://docs.microsoft.com/en-us/sysinternals/downloads/psexec).
2. Get process ID of RDP session using tasklist command. PowerShell script:

24 Chapter 5. Remote Execution Guide


pywinauto Documentation, Release 0.6.8

$session = tasklist /fo CSV | findstr RDP ; $session = $session.Split(",")[3] ; $session.Spl

3. Start process: PsExec.exe -s -i 123 python my_script.py.


Ansible (https://github.com/ansible/ansible) has PsExec plugin that simplifies it. Playbook example:
---
- name: test ra module
hosts: *****
tasks:
- name: run GUI automation
win_psexec:
command: python pywinauto_example.py
executable: C:\Windows\PSTools\psexec.exe
interactive: yes
username: admin
password: ******
hostnames: ******

Windows Scheduler is also capable to start jobs with GUI interaction support. There is easy way to schedule the task
from cmd.exe once:
Schtasks /Create /tn my_task /tr c:\temp\my_task.bat /sc ONCE /st hh:mi:ss /sd yyyy/mm/dd

5.6.1 How To‘s

• How To’s

5.6. Start remote script directly 25


pywinauto Documentation, Release 0.6.8

26 Chapter 5. Remote Execution Guide


CHAPTER 6

Methods available to each different control type

Windows have many controls, buttons, lists, etc

6.1 All Controls

These functions are aviailable to all controls.


• capture_as_image
• click
• click_input
• close
• close_click
• debug_message
• double_click
• double_click_input
• drag_mouse
• draw_outline
• get_focus
• get_show_state
• maximize
• menu_select
• minimize
• move_mouse
• move_window
• notify_menu_select
• notify_parent
• press_mouse
• press_mouse_input
• release_mouse

27
pywinauto Documentation, Release 0.6.8

• release_mouse_input
• restore
• right_click
• right_click_input
• send_message
• send_message_timeout
• set_focus
• set_window_text
• type_keys
• Children
• Class
• ClientRect
• ClientRects
• ContextHelpID
• ControlID
• ExStyle
• Font
• Fonts
• FriendlyClassName
• GetProperties
• HasExStyle
• HasStyle
• IsChild
• IsDialog
• IsEnabled
• IsUnicode
• IsVisible
• Menu
• MenuItem
• MenuItems
• Owner
• Parent
• PopupWindow
• ProcessID
• Rectangle
• Style

28 Chapter 6. Methods available to each different control type


pywinauto Documentation, Release 0.6.8

• Texts
• TopLevelParent
• UserData
• VerifyActionable
• VerifyEnabled
• VerifyVisible
• WindowText

6.2 Button, CheckBox, RadioButton, GroupBox

• ButtonWrapper.Check
• ButtonWrapper.GetCheckState
• ButtonWrapper.SetCheckIndeterminate
• ButtonWrapper.UnCheck

6.3 ComboBox

• ComboBoxWrapper.DroppedRect
• ComboBoxWrapper.ItemCount
• ComboBoxWrapper.ItemData
• ComboBoxWrapper.ItemTexts
• ComboBoxWrapper.Select
• ComboBoxWrapper.SelectedIndex

6.4 Dialog

• DialogWrapper.ClientAreaRect
• DialogWrapper.RunTests
• DialogWrapper.WriteToXML

6.5 Edit

• EditWrapper.GetLine
• EditWrapper.LineCount
• EditWrapper.LineLength
• EditWrapper.Select
• EditWrapper.SelectionIndices

6.2. Button, CheckBox, RadioButton, GroupBox 29


pywinauto Documentation, Release 0.6.8

• EditWrapper.SetEditText
• EditWrapper.set_window_text
• EditWrapper.TextBlock

6.6 Header

• HeaderWrapper.GetColumnRectangle
• HeaderWrapper.GetColumnText
• HeaderWrapper.ItemCount

6.7 ListBox

• ListBoxWrapper.GetItemFocus
• ListBoxWrapper.ItemCount
• ListBoxWrapper.ItemData
• ListBoxWrapper.ItemTexts
• ListBoxWrapper.Select
• ListBoxWrapper.SelectedIndices
• ListBoxWrapper.SetItemFocus

6.8 ListView

• ListViewWrapper.Check
• ListViewWrapper.ColumnCount
• ListViewWrapper.Columns
• ListViewWrapper.ColumnWidths
• ListViewWrapper.GetColumn
• ListViewWrapper.GetHeaderControl
• ListViewWrapper.GetItem
• ListViewWrapper.GetSelectedCount
• ListViewWrapper.IsChecked
• ListViewWrapper.IsFocused
• ListViewWrapper.IsSelected
• ListViewWrapper.ItemCount
• ListViewWrapper.Items
• ListViewWrapper.Select
• ListViewWrapper.Deselect

30 Chapter 6. Methods available to each different control type


pywinauto Documentation, Release 0.6.8

• ListViewWrapper.UnCheck

6.9 PopupMenu

(no extra visible methods)

6.10 ReBar

• ReBarWrapper.BandCount
• ReBarWrapper.GetBand
• ReBarWrapper.GetToolTipsControl

6.11 Static

(no extra visible methods)

6.12 StatusBar

• StatusBarWrapper.BorderWidths
• StatusBarWrapper.GetPartRect
• StatusBarWrapper.GetPartText
• StatusBarWrapper.PartCount
• StatusBarWrapper.PartRightEdges

6.13 TabControl

• TabControlWrapper.GetSelectedTab
• TabControlWrapper.GetTabRect
• TabControlWrapper.GetTabState
• TabControlWrapper.GetTabText
• TabControlWrapper.RowCount
• TabControlWrapper.Select
• TabControlWrapper.TabCount
• TabControlWrapper.TabStates

6.9. PopupMenu 31
pywinauto Documentation, Release 0.6.8

6.14 Toolbar

• ToolbarWrapper.Button
• ToolbarWrapper.ButtonCount
• ToolbarWrapper.GetButton
• ToolbarWrapper.GetButtonRect
• ToolbarWrapper.GetToolTipsControl
• ToolbarWrapper.PressButton
ToolbarButton (returned by Button())
• ToolbarButton.Rectangle
• ToolbarButton.Style
• ToolbarButton.click_input
• ToolbarButton.Click
• ToolbarButton.IsCheckable
• ToolbarButton.IsChecked
• ToolbarButton.IsEnabled
• ToolbarButton.IsPressable
• ToolbarButton.IsPressed
• ToolbarButton.State

6.15 ToolTips

• ToolTipsWrapper.GetTip
• ToolTipsWrapper.GetTipText
• ToolTipsWrapper.ToolCount

6.16 TreeView

• TreeViewWrapper.EnsureVisible
• TreeViewWrapper.GetItem
• TreeViewWrapper.GetProperties
• TreeViewWrapper.IsSelected
• TreeViewWrapper.ItemCount
• TreeViewWrapper.Root
• TreeViewWrapper.Select
TreeViewElement (returned by GetItem() and Root())
• TreeViewElement.Children

32 Chapter 6. Methods available to each different control type


pywinauto Documentation, Release 0.6.8

• TreeViewElement.Item
• TreeViewElement.Next
• TreeViewElement.Rectangle
• TreeViewElement.State
• TreeViewElement.SubElements
• TreeViewElement.Text

6.17 UpDown

• UpDownWrapper.GetBase
• UpDownWrapper.GetBuddyControl
• UpDownWrapper.GetRange
• UpDownWrapper.GetValue
• UpDownWrapper.SetValue
• UpDownWrapper.Increment
• UpDownWrapper.Decrement

6.17. UpDown 33
pywinauto Documentation, Release 0.6.8

34 Chapter 6. Methods available to each different control type


CHAPTER 7

Credits

(listed in reverse chronological order)


Vasily Ryabov, Valentin Kroupkin, Alexander Rumyantsev - MS UI Automation backend implementation
Ivan Magazinnik - mouse/keyboard input emulation on Linux
Maxim Samokhvalov - initial implementation of win32_hooks module
Intel Corporation - Vasily Ryabov revived and maintained the project during his work at Intel (pywinauto 0.5.x)
Valentin Kroupkin (airelil) - continuous integration (AppVeyor), many unit tests improvements (pywinauto 0.5.x)
Michael Herrmann - bug fixes, project maintenance (0.4.x)
Raghav - idea with using metaclass for finding wrapper
Daisuke Yamashita - Bugs/suggestions for 2.5 that MenuWrapper.GetProperties() returns a list rather then a dict
Dalius Dobravolskas - Help on the forums and prompted major improvements on the wait* functionality
Jeff Winkler - Early encouragement, creation of screencasts
Stefaan Himpe - Lots of speed and stability improvements early on

35
pywinauto Documentation, Release 0.6.8

36 Chapter 7. Credits
CHAPTER 8

Dev Notes

8.1 FILE LAYOUT

# used by just about everything (and considered a block!) win32defines.py win32functions.py win32structures.py
# Find windows and their attributes findwindows.py handleprops.py
# wrap windows, get extra info for particular controls # set the friendly class name controlscommon_controls.py
controlscontrolactions.py controlshwndwrapper.py controlswin32_controls.py
# currently depends on the Friendly class name # probably needs to be refactored to make it independent of controls!
# maybe move that stuff to _application_? findbestmatch.py # currently depends on controls!
controlactions.py
testsallcontrols.py testsasianhotkey.py testscomboboxdroppedheight.py testscomparetoreffont.py testslead-
trailspaces.py testsmiscvalues.py testsmissalignment.py testsmissingextrastring.py testsoverlapping.py testsre-
peatedhotkey.py teststranslation.py teststruncation.py
controlproperties.py
xml_helpers.py
FindDialog.py PyDlgCheckerWrapper.py
application.py test_application.py

8.2 Best matching

difflib provides this support For menu’s it is simple we match against the text of the menu item. For controls the story
is more complicated because we want to match against the following:
• Control text if it exists
• Friendly Class name
• Control text + Friendly class name (if control text exists)
• (Possibly) closest static + FriendlyClassName
e.g. FindWhatCombo, ComboBox1,
or Text, TextRiadio, RadioButton2
1. the control itself knows what it should be referred to

37
pywinauto Documentation, Release 0.6.8

2. Need to disambiguate across all controls in the dialog


3. then we need to match

8.3 ATTRIBUTE RESOLUTION

Thinking again... app.dlg.control


TWO LEVELS
• application.member (Python resolves) an attribute of application object
• application.dialog a dialog reference
THREE LEVELS
• application.member.attr (Python resolves) another attribute of the previous member
• application.dialog.member a member of the dialog object
• application.dialog.control a control on the dialog
FOUR LEVELS (leaving out Python resolved)
• application.dialog.member.member
• application.dialog.control.member
DELAYED RESOLUTION FOR SUCCESS Taking the example
app.dlg.control.action()

If we leave out syntax and programming errors there are still a number of reasons why it could fail.
dlg might not be found control might not be found either dlg or control may be disabled
dialog and control may be found but on the wrong dialog (e.g. in Notepad you can bring up 2 “Page Setup” dialogs
both with an OK button)
One solution would just be to add a “sleep” before trying to find each new dialog (to ensure that it is there and ready)
- but this will mean lots of unnecessary waiting.
So the solution I have tried is:
• perform the complete attribute access resolution at the latest possible time
• if it fails then wait and try again
• after a specified timeout fail raising the original exception.
This means that in the normal case you don’t have unnecessary waits - and in the failure case - you still get an exception
with the error.
Also waiting to do resolution as late as possible stops errors where an earlier part of the path succeedes - but finds the
wrong item.
So for example if finds the page setup dialog in Notepad # open the Printer setup dialog (which has “Page Setup” as
title) app.PageSetup.Printer.Click()
# if this runs too quickly it actually finds the current page setup dialog # before the next dialog opens, but that dialog
does not have a Properties # button - so an error is raised. # because we re-run the resolution from the start we find the
new pagesetup dialog. app.PageSetup.Properties.Click()

38 Chapter 8. Dev Notes


pywinauto Documentation, Release 0.6.8

8.4 WRITING TO DIALOGS

We need a way of making sure that the dialog is active without having to access a control on it. e.g.
app.MainWin.MenuSelect("Something That->Loads a Dialog")
app.Dlg._write("dlg.xml")

or a harder problem:
app.PageSetup.Printer.Click()
app.PageSetup._write("pagesetup.xml")

In this second example it is very hard to be sure that the correct Page Setup dialog is shown.
The only way to be realy sure is to check for the existance of certain control(s) (ID, Class, text, whatever) - but it
would be nice to not have to deal with those :-(
Another less declarative (more magic?) is to scan the list of available windows/controls and if they haven’t changed
then accept that the correct one is shown.
When testing and having XML files then we should use those to make sure that we have the correct dialog up (by
using Class/ID)

8.4. WRITING TO DIALOGS 39


pywinauto Documentation, Release 0.6.8

40 Chapter 8. Dev Notes


CHAPTER 9

PYWINAUTO TODO’s

• Make sure to add documentation strings for all undocumented methods/functions


• Check coverage of the tests and work to increase it.
• Add tests for SendInput click methods
• Implement findbestmatch using FuzzyDict.
• Find a way of doing application data in a better way. Currently if someone even adds a call to
print_control_identifiers() it will break the matching algorithm!
• Need to move the checking if a control is a Ownerdrawn/bitmap control out of __init__ methods and into it’s
own method something like IsNormallyRendered() (Why?)
• Give example how to work with Tray Window
• Fix ToolbarWrapper.PressButton() which doesn’t seem to work (found wile working on IE example script)
• Maybe supply an option so that scripts can be run by using:
pywinauto.exe yourscript.py

This would work by creating a Py2exe wrapper that would import the script (and optionally call a particular
function?)
This way pywinauto could be made available to people without python installed (whether this is a big require-
ment or not I don’t know because the automation language is python anyway!.
• Message traps - how to handle unwanted message boxes popping up?
1. Wait for an Exception then handle it there
2. set a trap waiting for a specific dialog
3. on calls to window specification, if we fail to find our window then we can run quickly through the available
specified traps to see if any of them apply - then if they do we can run the associated actions - then try our
original dialog again
• Handle adding reference controls (in that they should be the controls used for finding windows)
• Find the reference name of a variable e.g so that in Dialog._write() we can know the variable name that called
the _write on (this we don’t have to repeat the XML file name!)
• If we remove the delay after a button click in controlactions then trying to close two dialogs in a row might
fail because the first dialog hasn’t closed yet and the 2nd may have similar title and same closing button e.g
PageSetup.OK.Click(), PageSetup2.OK.Click(). A possible solution to this might be to keep a cache of windows
in the application and no two different dialog identifiers (PageSetup and PageSetup2 in this case) can have the

41
pywinauto Documentation, Release 0.6.8

same handle - so returning the handle of PageSetup when we call PageSetup2 would fail (and we would do our
usual waiting until it succeeds or times out).
• Investigate using any of the following
– BringWindowToTop: probably necessary before image capture
– GetTopWindow: maybe to re-set top window after capture?
– EnumThreadWindows
– GetGUIThreadInfo
• Make it easy to work with context(right click) menu’s
• Further support .NET controls and download/create a test .NET application
• Look at supporting the Sytem Tray (e.g. right click on an icon)
• supply SystemTray class (singleton probably)
• Look at clicking and text input - maybe use SendInput
• Support Up-Down controls and other common controls
• Find out whether control.item.action() or control.action(item) is better
• Create a Recorder to visually create tests
LOW PRIORITY
• Create a class that makes it easy to deal with a single window (e.g. no application)
• Allow apps to be started in a different thread so we don’t lock up
– this is being done already - the problem is that some messages cannot be sent across processes if they have
pointers (so we need to send a synchronous message which waits for the other process to respond before
returning)
– But I guess it would be possible to create a thread for sending those messages?
• Liberate the code from HwndWrapper - there is very little this add’s beyond what is available in handleprops.
The main reason this is required is for the FriendlyClassName. So I need to look to see if this can be moved
elsewhere.
Doing this might flatten the heirarchy quite a bit and reduce the dependencies on the various packages
• Need to make Menu items into classes so instead of Dlg.MenuSelect we should be doing
dlg.Menu("blah->blah").select()

or even
dlg.Menu.Blah.Blah.select()

To do this we need to change how menu’s are retrieved - rather than get all menuitems at the start - then
we just get the requested level.
This would also enable things like
dlg.Menu.Blah.Blah.IsChecked() IsEnabled(), etc

42 Chapter 9. PYWINAUTO TODO’s


pywinauto Documentation, Release 0.6.8

9.1 CLOSED (in some way or the other)

• Allow delay after click to be removed. The main reason that this is needed at the moment is because if you close
a dialog and then try an action on the parent immediately it may not yet be active - so the delay is needed to
allow it to become active. To fix this we may need to add more magic around calling actions on dialogs e.g. on
an attribute access for an ActionDialog do the following:
– Check if it is an Action
– If it is not enabled then wait a little bit
– If it is then wait a little bit and try again
– repeat that until success or timeout
The main thing that needs to be resolved is that you don’t want two of these waits happening at once (so a wait
in a function at 1 level, and another wait in a function called by the other one - because this would mean there
would be a VERY long delay while the timeout of the nested function was reached the number of times the
calling func tried to succeed!)
• Add referencing by closest static (or surrounding group box?)
• Need to modularize the methods of the common_controls because at the moment they are much too monolithic.
• Finish example of saving a page from IE
• Document that I have not been able to figure out how to reliably check if a menu item is enabled or not before
selecting it. (Probably FIXED NOW!)
For Example in Media Player if you try and click the View->Choose Columns menu item when it is not enabled
it crashes Media Player. Theoretically MF_DISABLED and MF_GRAYED should be used - but I found that
these are not updated (at least for Media Player) until they are dropped down.
• Implement an opional timing/config module so that all timing can be customized

9.1. CLOSED (in some way or the other) 43


pywinauto Documentation, Release 0.6.8

44 Chapter 9. PYWINAUTO TODO’s


CHAPTER 10

Change Log

10.1 0.6.8 Bug Fixes

27-October-2019
Enhancements:
• Add allow_magic_lookup flag for Application and Desktop object. Thanks pakal
(https://github.com/pakal)!
• Don’t duplicate already pressed key in internal list in win32_hooks.py. Thanks TomRobo237
(https://github.com/TomRobo237)!
• Allow finding an edit box by title (its editable text).
• Add option to send keyboard input for an application which doesn’t handle VK_PACKET properly. Use
vk_packet=False in method type_keys, default value is vk_packet=True. Thanks philmbailey
(https://github.com/philmbailey)!
Bug Fixes:
• Fix ctypes.windll usage conflicts with other libraries.
• Minor fixes in top-level __init__.py. Thanks pakal (https://github.com/pakal)!
• Fix logging issues in remote_memory_block.py. Thanks TomRobo237
(https://github.com/TomRobo237)!
• Minor docs improvements. Thanks olesteban (https://github.com/olesteban), caoyaxing221
(https://github.com/caoyaxing221) and nuno-andre (https://github.com/nuno-andre)!

10.2 0.6.7 Bug Fixes

07-July-2019
Enhancements:
• Reuse ctypes.wintypes more to avoid redundant definitions for Win32 API.
• Add method EditWrapper.is_editable() for “uia” backend.
Bug Fixes:
• Fix corner case with int/long conversion crash while getting text.
• Fix UIA crash: handle InvalidControlType properly.

45
pywinauto Documentation, Release 0.6.8

• Fix menu_select() for one level main menu in WinForms apps.


• Make Application object non-iterable (iterating was hang).
• Fix type conversion crash in GetWindowRect (method .rectangle()).
• Fix combo box fluttering/blinking in dump_tree() / print_control_identifiers().

10.3 0.6.6 Better WinForms/Qt5 Support, Bug Fixes

03-March-2019
Enhancements:
• Improve support for WinForms and Qt5: ComboBox, ListBox, DataGrid/Table.
• Add an ability to use MFC toolbar buttons by text. Thanks Nebyt (https://github.com/Nebyt)!
• Make method kill() hard (and fast) by default (can be used with param soft=True optionally).
• Make visible_only=False a default option for method connect() (useful for minimized apps).
• Add an ability to hold or release a key with params down and up for .type_keys() method. See the
improved docs for keyboard module for more details. Thanks badari412 (https://github.com/badari412)!
• Add method windows() to class Desktop.
• Add Remote Execution Guide with all known RDP/VNC/psexec/etc tricks.
Bug Fixes:
• Fix UnicodeDecodeError/UnicodeEncodeError in several cases while printing wrapper object
representation.
• Add static text to a list of best match names for backend="uia".
• Fix COMError for runtime_id property.
• Fix method click() for some radio buttons.
• Improve error message when screen is locked.
• Use utf-8 encoding while writing dump_tree() output to file.
• Remove few incorrect warnings for backend="win32".
• Fix crash in GetWindowRect call.
• Fix black screenshot issue with second monitor. Thanks Nebyt (https://github.com/Nebyt)!

10.4 0.6.5 Handling Privileges, AutomationID for Win32 etc.

30-July-2018
Enhancements:
• Check admin privileges for both target app and Python process. This allows detecting cases when window
messages won’t work.
• Add automation_id and control_type properties for “win32” backend (the most useful for Win-
Forms). Correct child_window() keywords are auto_id and control_type.
• Switch pypiwin32 dependency to pywin32 which became official again.

46 Chapter 10. Change Log


pywinauto Documentation, Release 0.6.8

• New generators iter_children() and iter_descendants().


• Add method is_checked() to “win32” check box.
Bug Fixes:
• Method Application().connect(...) works better with timeout argument.
• Fix .set_focus() for “uia” backend including minimized window case (issue #443).
• maximize()/minimize() methods can be chained now.
• Fix passing keyword arguments to a function for decorators @always_wait_until_passes and
@always_wait_until.
• Use correct types conversion for WaitGuiThreadIdle (issue #497).
• Fix reporting code coverage on Linux.
• Use .format() for logging BaseWrapper actions (issue #471).
• Print warning in case binary type is not determined (issue #387).

10.5 0.6.4 NULL pointer access fix and enhancements

21-January-2018
Bug Fixes:
• Final fix for ValueError: NULL COM pointer access.
Enhancements:
• Multi-threading mode (MTA) for comtypes is enabled by default, if it’s not initialized by another library
before importing pywinauto.
• Method get_value() has been added to EditWrapper in UIA backend.
• Method scroll() has been added for all UIA controls which have ScrollPattern implemented.
• Added methods is_minimized/is_maximized/is_normal/get_show_state for UIAWrap-
per.
• Added handling in-place controls inside ListView control and (row, column) indexing in a grid-like table
mode. Examples:
auto_detected_ctrl = list_view.get_item(0).inplace_control()

combo = list_view.get_item(1,1).inplace_control("ComboBox")
combo.select("Item name")

edit = list_view.get_item(3,4).inplace_control("Edit")
edit.type_keys("some text{ENTER}", set_foreground=False)

dt_picker = list_view.get_item(2,0).inplace_control("DateTimePicker")

10.6 0.6.3 A lot of improvements and some optimizations

03-July-2017
• Improved string representation for all wrapper objects. Thanks airelil (https://github.com/airelil)!

10.5. 0.6.4 NULL pointer access fix and enhancements 47


pywinauto Documentation, Release 0.6.8

• Fixed several sporadic crashes for backend="uia".


• Fixed several bugs in wait/wait_not methods:
– Method wait(’exists’) doesn’t work for backend="uia". Thanks maollm
(https://github.com/maollm)!
– Methods wait/wait_not take ~ default time (5 sec.) instead of customized timeout like 1 sec.
• depth param can used in a WindowSpecification now. depth=1 means this control, depth=2
means immediate children only and so on (aligned with print_control_identifiers method).
Thanks dmitrykazanbaev (https://github.com/dmitrykazanbaev)!
• Significantly improved sending keys to an inactive window silently. Special thanks for antonlarin
(https://github.com/antonlarin)! Now 2 methods are available:
– send_chars is supposed to send character input (this includes {Enter}, {Tab},
{Backspace}) without Alt/Shift/Ctrl modifiers.
– send_keystrokes is for key input (including key combinations with Alt/Shift/Ctrl modifiers).
• Method Application().connect(path=’your.exe’) uses default timeout
Timings.app_connect_timeout. It can accept timeout and retry_interval keyword
arguments. Thanks daniil-kukushkin (https://github.com/daniil-kukushkin)!
• Method print_control_identifiers is more consistent and minimum 2x faster now! Thanks
cetygamer (https://github.com/cetygamer)!
• Fixed subclassing Application with your own methods. Thanks efremovd
(https://github.com/efremovd)!
• Param work_dir can be used in Application().start(...). Thanks efremovd
(https://github.com/efremovd)!
• Class Application has been enriched with methods is_process_running() and
wait_for_process_exit(). Thanks efremovd (https://github.com/efremovd)!
• Module timings uses time.clock() for Python 2.x and time.perf_counter() for Python
3.x so that accident system time change can’t affect on your script behavior. Thanks airelil
(https://github.com/airelil)!
• Added WireShark example. Thanks ViktorRoy94 (https://github.com/ViktorRoy94)!
• Now print_control_identifiers() can dump UI elements tree to a file. Thanks sovrasov
(https://github.com/sovrasov)!
• Improved logging actions for backend="uia", extended example for MS Paint. Thanks ArtemSkre-
bkov (https://github.com/ArtemSkrebkov)!
• Extended CalendarWrapper for backend="win32" with these methods: get_month_delta,
set_month_delta and get_month_range. Thanks Nikita-K (https://github.com/Nikita-K)!
• Added method legacy_properties() to UIAWrapper. Thanks AsyaPronina
(https://github.com/AsyaPronina)!
• Improved VB6 ListView detection for backend="win32". Thanks KirillMoizik
(https://github.com/KirillMoizik)!
• Fixed 64-bit specific bug in TreeViewWrapper for backend="win32" (argument 4: <type
’exceptions.OverflowError’>: long int too long to convert).

48 Chapter 10. Change Log


pywinauto Documentation, Release 0.6.8

10.7 0.6.2 More bug fixes

28-February-2017
• Several bugs were fixed:
– Maximized window is always resized (restored) when calling set_focus().
– AttributeError: type object ‘_CustomLogger’ has no attribute ‘disable’.
– print_control_identifiers() gets bytes string on Python 3.x.
– Importing pywinauto causes debug messages to appear twice.
• Improved click methods behaviour for Win32 ListView and TreeView: ensure_visible() is called
inside before the click.
• Made taskbar.SystemTrayIcons localization friendly.

10.8 0.6.1 Bug fixes and optimizations for UI Automation and beyond

08-February-2017
• win32_hooks module is well tested and more reliable now. See detailed example
(https://github.com/pywinauto/pywinauto/blob/master/examples/hook_and_listen.py).
• Fixed several bugs and crashes here and there.
– Crash when ctrl.window_text() becomes None at the right moment. Thanks mborus
(https://github.com/mborus)!
– HwndWrapper.set_focus() fails when used via interpreter. Thanks Matthew Kennerly
(https://github.com/mtkennerly)!
– Fix LoadLibrary call error on just released Python 2.7.13. Thanks Kirill Moizik
(https://github.com/KirillMoizik)!
– AttributeError: WindowSpecification class has no ‘CPUUsage’ method.
– comtypes prints a lot of warnings at import pywinauto.
– Methods is_dialog() and restore() are missed for UIA backend.
– Method print_control_identifiers() crashes on some applications with Unicode sym-
bols.
– Installation by python setup.py install may fail if pyWin32 dependency was installed man-
ually.
– Bug in resolving attributes: ‘UIAWrapper’ object has no attribute ‘Menu’ for dlg =
app.Custom.Menu
– Method send_chars() can now send {ENTER} to some applications. Thanks Max Bolingbroke
(https://github.com/batterseapower)!
• Searching UI elements is faster now especially if you use control_type or auto_id in a Win-
dowSpecification. Method Application.kill() is also optimized in many cases.
• Added an example for Win10 Calculator (https://github.com/pywinauto/pywinauto/blob/master/examples/win10_calculator.p

10.7. 0.6.2 More bug fixes 49


pywinauto Documentation, Release 0.6.8

10.9 0.6.0 Introduce MS UI Automation support and many more im-


provements

30-October-2016
• This big release introduces MS UI Automation (UIA) support:
– Just start from app = Application(backend=’uia’).start(’your_app.exe’).
– Supported controls: Menu, Button/CheckBox/RadioButton, ComboBox, Edit, Tab control, List
(ListView), DataGrid, Tree, Toolbar, Tooltip, Slider.
• Documentation is built continuously now on ReadTheDocs. See also improved Getting Started Guide.
• New multi-backend architecture makes implementation of new platforms support easier in the fu-
ture. The minimal set for new backend includes its name and two classes inherited from
element_info.ElementInfo and from pywinauto.base_wrapper.BaseWrapper. New
backend must be registered by function pywinauto.backend.register().
• Code style is much closer to PEP8: i.e. click_input should be used instead of ClickInput.
• Initial implementation of the win32_hooks module. Keyboard and mouse event handlers can be regis-
tered in the system. It was inspired by pyHook, pyhk, pyhooked and similar modules, but re-written from
scratch. Thanks for Max Samokhvalov! The fork of the win32_hooks module is used in pyhooked 0.8
by Ethan Smith.
• A lot of small improvements are not counted here.

10.10 0.5.4 Bug fixes and partial MFC Menu Bar support

30-October-2015
• Fix bugs and inconsistencies:
– Add where=”check” possible value to the ListViewWrapper.Click/ClickInput‘ methods.
– Add CheckByClickInput and UncheckByClickInput methods for a plain check box.
– Fix crash while waiting for the window start.
• Add partial MFC Menu Bar support. The menu bar can be interpreted as a toolbar. Items are clickable by
index through experimental MenuBarClickInput method of the ToolbarWrapper.
• Python 3.5 is supported.

10.11 0.5.3 Better Unicode support for SetEditText/TypeKeys and


menu items

25-September-2015
• Better backward compatibility with pywinauto 0.4.2:
– support Unicode symbols in the TypeKeys method again;
– allow SetEditText/TypeKeys methods to take non-string arguments;
– fix taking Unicode parameters in SetEditText/TypeKeys.

50 Chapter 10. Change Log


pywinauto Documentation, Release 0.6.8

• Fix bug in Wait("active"), raise a SyntaxError when waiting for an incorrect state.
• Re-consider some timings, update docs for the default values etc.
• Fix several issues with an owner-drawn menu.
• MenuItem method Click is renamed to ClickInput while Click = Select now.
• New SetTransparency method can make a window transparent in a specified degree.

10.12 0.5.2 Improve ListView, new methods for CPU usage, DPI
awareness

07-September-2015
• New Application methods: CPUUsage returns CPU usage as a percent (float number),
WaitCPUUsageLower waits until the connected process’ CPU usage is lower than a specified value
(2.5% by default).
• A new class _listview_item. It is very similar to _treeview_element.
• Add DPI awareness API support (Win8+). It allows correct work when all fonts are scaled at 125%, 150% etc
(globally or per monitor).
• “Tools overview” section in docs.
• Fix number of bugs:
– TreeViewWrapper.Select doesn’t work when the control is not in focus.
– TabControlWrapper.Select doesn’t work in case of TCS_BUTTONS style set.
– ListViewWrapper methods Check/UnCheck are fixed.
– Toolbar button: incorrect access by a tooltip text.
– Warning “Cannot retrieve text length for handle” uses print() instead of actionlogger.
– ClientToScreen method doesn’t return a value (modifying mutable argument is not good practice).

10.13 0.5.1 Several fixes, more tests

13-July-2015
• Resolve pip issues
• Warn user about mismatched Python/application bitness (64-bit Python should be used for 64-bit application
and 32-bit Python is for 32-bit app)
• Add “TCheckBox” class name to ButtonWrapper detection list
• Fix DebugMessage method
• Disable logging (actionlogger.py) by default, provide shortcuts: actionlogger.enable() and
actionlogger.disable(). For those who are familiar with standard logging module there’s method
actionlogger.set_level(level)

10.12. 0.5.2 Improve ListView, new methods for CPU usage, DPI awareness 51
pywinauto Documentation, Release 0.6.8

10.14 0.5.0 64-bit Py2/Py3 compatibility

30-June-2015
• 64-bit Python and 64-bit apps support (but 32-bit Python is recommended for 32-bit apps)
• Python 2.x/3.x compatibility
• Added pyWin32 dependency (silent install by pip for 2.7 and 3.1+)
• Improvements for Toolbar, TreeView, UpDown and DateTimePicker wrappers
• Improved best_match algorithm allows names like ToolbarFile
• Clicks can be performed with pressed Ctrl or Shift
• Drag-n-drop and scrolling methods (DragMouse, DragMouseInput, MouseWheelInput)
• Improved menu support: handling OWNERDRAW menu items; access by command_id (like $23453)
• Resolved issues with py2exe and cx_freeze
• RemoteMemoryBlock can now detect memory corruption by checking guard signature
• Upgraded taskbar module
• sysinfo module for checking 32-bit or 64-bit OS and Python
• set_foreground flag in TypeKeys method for typing into in-place controls
• flags create_new_console and wait_for_idle in Application.start method

10.15 0.4.0 Various cleanup and bug fixes

03-April-2010
• Gracefully Handle dir() calls on Application or WindowSpecification objects (which used hang for a while as
these classes would search for windows matching __members__, __methods__ and __bases__). The code now
checks for any attribute that starts with ‘__’ and ends with ‘__’ and raises AttributeError immediately. Thanks
to Sebastian Haase for raising this.
• Removed the reference to an Application object in WindowSpecification. It was not used in the class and made
the class harder to use. WindowSpecification is now more useful as a utility class.
• Add imports of application.WindowSpecification and application.Application to pywinauto.__init__.py so that
these classes can be used more easily (without having to directly import pywinauto.application). Thanks again
to Sebastian Haase.
• Added a function to empty the clipboard (thanks to Tocer on Sourceforge)
• Use ‘SendMessageTimeout’ to get the text of a window. (SendMessage will hang if the application is not
processing messages)
• Fixed references to PIL.ImageGrab. PIL add’s it’s module directly to the module path, so it should just be
referenced by ImageGrab and not PIL.ImageGrab.
• Use AttachThreadInput + PostMessage rather than SendMessageTimeout to send mouse clicks.
• Fix how timeout retry times are calculated in timings.WaitUntil() and timings.Wait
• Fixed some issues with application.Kill_() method, highlighted due to the changes in the HwndWrapper.Close()
method.

52 Chapter 10. Change Log


pywinauto Documentation, Release 0.6.8

• Fix writing images to XML. It was broken with updates to PIL that I had not followed. Changed the method of
knowing if it is an image by checking for various attributes.
• Renamed WindowSpecification.(Ww)indow() to ChildWindow() and added deprecation messages for the other
functions.
• Improved the tests (fixed test failures which were not pywinauto issues)

10.16 0.3.9 Experimental! New Sendkeys, and various fixes

27-November-2009
• Major change this release is that Sendkeys is no longer a requirement! A replacement that supports Unicode is
included with pywinauto. (hopefully soon to be released as a standalone module). Please note - this is still quite
untested so this release should be treated with some care..
• Made sure that default for WindowSpecification.Window_() was to look for non top level windows. The defaults
in find_windows() had been changed previously and it now needed to be explicitly overridden.
• Fixed a missing reference to ‘win32defines’ when referencing WAIT_TIMEOUT another typo of false (changed
to False)
• Removed the restriction to only get the active windows for the process, now it will be possible to get the active
windows, even if a process is not specified. From http://msdn.microsoft.com/en-us/library/ms633506%28VS.
85%29.aspx it gets the active window for the foreground thread.
• Hopefully improved Delphi TreeView and ListView handling (added window class names as supported window
classes to the appropriate classes).
• Added support for running UI tests with reference controls. (requried for some localization tests)
• Various PyLint and PEP8 fixes made.

10.17 0.3.8 Collecting improvements from last 2 years

10-March-2009
• Fixed toolbar button pressing - This required for HwndWrapper.NotifyParent() to be updated (to accept a new
ID parameter)
• Fixed a bug wherea listview without a column control would make pywinauto fail to capture the dialog.
• Converted documenation from Pudge generated to Sphinx Generated
• Added some baic support for Pager and Progress controls (no tests yet)
• Added some more VB ‘edit’ window classes
• Added some more VB ‘listbox’ window classes
• Added some more VB ‘button’ window classes
• Ensured that return value from ComboBoxWrapper.SelectedIndices is always a tuple (there was a bug where it
would sometimes be a ctypes array)
• Changed default for finding windows to find disabled windows as well as enabled ones (previous was to find
enabled windows only) (note this may impact scripts that relied on the previous setting i.e. in cases where two
dialogs have the same title!)

10.16. 0.3.9 Experimental! New Sendkeys, and various fixes 53


pywinauto Documentation, Release 0.6.8

• Much better handling of InvalidWindowHandle during automation runs. This could be raised when a closing
window is still available when the automation was called, but is gone half way through whatever function was
called.
• Made clicking more robust by adding a tiny wait between each SendMessageTimeout in _perform_click().
• Added attributes can_be_label and has_title to HwndWrapper and subclasses to specify whether a
control can act as a label for other controls, and whether the title should be used for identifying the control. If
you have created your own HwndWrapper subclasses you may need to override the defaults.
• Added a control_id parameter to find_windows which allows finding windows based off of their control
id’s
• Added a FriendlyClassName method to MenuItem
• Split up the functions for button truncation data
• Commented out code to get a new font if the font could not be recovered
• Moved code to get the control font from Truncation test to handleprops
• Added a function to get the string representation of the bug. (need to refactor PrintBugs at some point).
• Fixed a variable name (from fname -> font_attrib as fname was not a defined variable!)
• Forced some return values from MissingExtraString test to be Unicode
• Fixed the MiscValues test (converted to Unicode and removed some extraneous characters)
• Updated the path for all unittests
• Made two unit tests sligthly more robust and less dependent on computer/app settings
• Updated timing settings for unit tests
• Updated the examples to work in dev environment.

10.18 0.3.7 Merge of Wait changes and various bug


fixes/improvements

10-April-2007
• Added Timings.WaitUntil() and Timings.WaitUntilPasses() which handle the various wait until something in
the code. Also refactored existing waits to use these two methods.
• Fixed a major Handle leak in RemoteMemorBlock class (which is used extensively for ‘Common’ controls. I
was using OpenHandle to open the process handle, but was not calling CloseHandle() for each corresponding
OpenHandle().
• Added an active_() method to Application class to return the active window of the application.
• Added an ‘active’ option to WindowSpecification.Wait() and WaitNot().
• Some cleanup of the clipboard module. GetFormatName() was improved and GetData() made a little more
robust.
• Added an option to findwindows.find_windows() to find only active windows (e.g. active_only = True). Default
is False.
• Fixed a bug in the timings.Timings class - timing values are Now accessed through the class (Timings) and not
through the intance (self).

54 Chapter 10. Change Log


pywinauto Documentation, Release 0.6.8

• Updated ElementTree import in XMLHelpers so that it would work on Python 2.5 (where elementtree is a
standard module) as well as other versions where ElementTree is a separate module.
• Enhanced Item selection for ListViews, TreeViews - it is now possible to pass strings and they will be searched
for. More documentation is required though.
• Greatly enhanced Toolbar button clicking, selection, etc. Though more documentation is required.
• Added option to ClickInput() to allow mouse wheel movements to be made.
• menuwrapper.Menu.GetProperties() now returns a dict like all other GetProperties() methods. This dict for now
only has one key ‘MenuItems’ which contains the list of menuitems (which had been the previous return value).

10.19 0.3.6b Changes not documented in 0.3.6 history

31-July-2006
• Fixed a bug in how findbestmatch.FindBestMatches was working. It would match against text when it should
not!
• Updated how timings.Timings.Slow() worked, if any time setting was less then .2 after ‘slowing’ then set it to
.2

10.20 0.3.6 Scrolling and Treview Item Clicking added

28-July-2006
• Added parameter to _treeview_item.Rectangle() to have an option to get the Text rectangle of the
item. And defaulted to this.
• Added _treeview_item.Click() method to make it easy to click on tree view items.
• Fixed a bug in TreeView.GetItem() that was expanding items when it shouldn’t.
• Added HwndWrapper.Scroll() method to allow scrolling. This is a very minimal implementation - and if
the scrollbars are implemented as separate controls (rather then a property of a control - this will probably not
work for you!). It works for Notepad and Paint - that is all I have tried so far.
• Added a call to HwndWrapper.SetFocus() in _perform_click_input() so that calls to
HwndWrapper.ClickInput() will make sure to click on the correct window.

10.21 0.3.5 Moved to Metaclass control wrapping

24-May-2006
• Moved to a metaclass implementation of control finding. This removes some cyclic importing that had to be
worked around and other then metaclass magic makes the code a bit simpler.
• Some of the sample files would not run - so I updated them so they would (Thanks to Stefaan Himpe for pointing
this out)
• Disabled saving application data (it was still being saved in Application.RecordMatch() even if the rest of the
application data code is disabled. This was causing what appeared to be a memory leak where pywinauto would
keep grabbing more and more memory (especially for controls that contain a lot of information). Thanks to
Frank Martinez for leading me to this).

10.19. 0.3.6b Changes not documented in 0.3.6 history 55


pywinauto Documentation, Release 0.6.8

• Added ListViewWrapper.GetItemRect() to enable retrieving the rectangle for a particular item in the listview.
• Removed references to _ctrl() method within pywinauto as it was raising a DeprecationWarning internally even
if the user was not using it.

10.22 0.3.4 Fixed issue with latest ctypes, speed gains, other
changes

25-Apr-2006
• The latest version of ctypes (0.9.9.6) removed the code generator I was using some generated code in
win32functions.py (stdcall). I was not using those functions so I just commented them out.
• Started the process of renaming methods of the Application and WindowSpecification classes. I will
be converting names to UppercaseNames_(). The trailing _ is to disambiguate the method names from
potential Window titles.
• Updated how print_control_identifiers works so that it now always prints the disambiguated control name. (even
for single controls)
• Added __hash__ to HwndWrapper so that controls could be dictionary keys.
• Caching various information at various points. For example I cache how well two pieces of text match. For short
scripts this has little impact - but for larger script it could well have a major impact. Also caching information
for controls that cannot change e.g. TopLeveParent, Parent, etc

10.23 0.3.3 Added some methods, and fixed some small bugs

19-Apr-2006
• Added a wait for the control to be active and configurable sleeps after ‘modifying’ actions (e.g. Select, Deselect,
etc)
• Fixed Timings.Slow() and Timings.Fast() - they could in certain circumstances do the opposite! If you had
already set a timing slower or faster then they would set it then they would blindly ignore that and set their own
times. I added functionality that they will take either the slowest or fastest of the new/current setting rather then
blindly setting to the new value.
• Fixed some hidden bugs with HwndWrapper.CloseClick()
• Fixed a bug in setup.py that would raise an error when no argument was specified
• Added an argument to HwndWrapper.SendMessageTimeout so that the wait options could be passed in.
• Added HwndWrapper.Close(), Maximize(), Minimize(), Restore() and GetShowState().
• Commented out all deprecated methods (will be removed completely in some future release).
• Added Application.kill_() method - which closes all windows and kills the application. If the application is
asking if you want to save your changes - you will not be able to click yes or no and the application will be
killed anyway!.

10.24 0.3.2 Fixed setup.py and some typos

31-Mar-2006

56 Chapter 10. Change Log


pywinauto Documentation, Release 0.6.8

• Fixed the spelling of Stefaan Himpe’s name


• Fixed setup.py which was working for creating a distribution but not for installing it (again thanks to Stefaan for
pointing it out!)

10.25 0.3.1 Performance tune-ups

30-Mar-2006
• Change calculation of distance in findbestmatch.GetNonTextControlName() so that it does not need to square
or get the square root to find the real distance - as we only need to compare values - not have the actual distance.
(Thanks to Stefaan Himpe)
• Compiled regular expression patterns before doing the match to avoid compiling the regular expression for
window that is being tested (Thanks to Stefaan Himpe)
• Made it easier to add your own control tests by adding a file extra_tests.py which needs to export a ModifyReg-
isteredTests() method. Also cleaned up the code a little.
• Updated notepad_fast.py to make it easier to profile (adde a method)
• Changed WrapHandle to use a cache for classes it has matched - this is to avoid having to match against all
classes constantly.
• Changed default timeout in SendMessageTimeout to .001 seconds from .4 seconds this results in a significant
speedup. Will need to make this value modifiable via the timing module/routine.
• WaitNot was raising an error if the control was not found - it should have returned (i.e. success - control is not
in any particular state because it does not exist!).
• Added ListViewWrapper.Deselect() per Chistophe Keller’s suggestion. While I was at it I added a check on
the item value passed in and added a call to WaitGuiIdle(self) so that the control has a chance to process the
message.
• Changed doc templates and moved dependencies into pywinauto subversion to ensure that all files were availabe
at www.openqa.org and that they are not broken when viewed there.
• Moved all timing information into the timings.Timings class. There are some simple methods for changing the
timings.

10.26 0.3.0 Added Application data - now useful for localization test-
ing

20-Mar-2006
• Added automatic Application data collection which can be used when running the same test on a different
spoken language version. Support is still preliminary and is expected to change. Please treat as early Alpha.
If you have a different language version of Windows then you can try this out by running the notepad_fast.py
example with the langauge argument e.g.
examples\notepad_fast.py language

This will load the application data from the supplied file notepad_fast.pkl and use it for finding the right menu
items and controls to select.
• Test implementation to make it easier to start using an application. Previously you needed to write code like

10.25. 0.3.1 Performance tune-ups 57


pywinauto Documentation, Release 0.6.8

app = Application().connect_(title = 'Find')


app.Find.Close.Click()
app.NotePad.MenuSelect("File->Exit")

1st change was to implement static methods start() and connect(). These methods return a new Appli-
cation instance so the above code becomes:
app = Application.connect(title = 'Find')
app.Find.Close.Click()
app.NotePad.MenuSelect("File->Exit")

I also wanted to make it easier to start working with a simple application - that may or may not have only one
dialog. To make this situation easier I made window_() not throw if the application has not been start()ed
or connect()ed first. This leads to simpler code like:
app = Application()
app.Find.Close.Click()
app.NotePad.MenuSelect("File->Exit")

What happens here is that when you execute any of Application.window_(), Application.__getattr__() or Ap-
plication.__getitem__() when the application hasn’t been connected or started. It looks for the window that best
matches your specification and connects the application to that process.
This is extra functionality - existing connect_() and start_() methods still exist
• Fixed HwndWrapper.SetFocus() so that it would work even if the window was not in the foreground. (it now
makes the window foreground as well as giving it focus). This overcomes a restriction in Windows where you
can only change the foreground window if you own the foreground window.
• Changed some 2.4’isms that an anonymous commenter left on my blog :-) with these changes pywinauto should
run on Python 2.3 (though I haven’t done extensive testing).
• Commented out controls.common_controls.TabControlWrapper.GetTabState() and TabStates() as these did not
seem to be returning valid values anyway.
• Fixed documentation issues were parts of the documentation were not getting generated to the HTML files.
• Fixed issue where MenuSelect would sometimes not work as expected. Some Menu actions require that the
window that owns the menu be active. Added a call to SetFocus() before selecting a menu item to ensure that
the window was active.
• Fixed Bug 1452832 where clipboard was not closed in clipboard.GetData()
• Added more unit tests now up to 248 from 207

10.27 0.2.5 More refactoring, more tests

07-Mar-2006
• Added wrapper classes for Menus and MenuItems this enabled cleaner interaction with Menu’s. It also gives
more functionality - you can now programmatically Click() on menus, and query if a menu item is checked or
not.
• Added application.WindowSpecification.Wait() and WaitNot() methods. These methods allow you to wait for
a control to exist, be visible, be enabled, be ready (both enabled and visible!) or to wait for the control to not
be in any of these states. WaitReady(), WaitNotEnabled(), WaitNotVisible() now use these methods. I was able
to also add the missing methods WaitNotReady(), WaitEnabled(), WaitVisible(), WaitExists(), WaitnotExists().
Please use Wait() and WaitNot() as I have Deprecated these Wait* methods.

58 Chapter 10. Change Log


pywinauto Documentation, Release 0.6.8

• Slightly modified timeout waits for control resolution so that a timed function more accurately follows the
timeout value specified.
• Added application.Application.start() and connect() static methods. These methods are factory methods in that
they will return an initialized Application instance. They work exactly the same as start_() and connect() as they
are implemented in terms of those.
from pywinauto.application import Application notepad = Application.start(“notepad”)
same_notepad = Application.connect(path = “notepad”)
• Updated the examples to follow changes to the code - and to make them a little more robust.
• Added a new Controls Overview document page which lists all the actions on all controls.
• Added more unit tests now up to 207 from 134 (added 68 tests)

10.28 0.2.1 Small Release number - big changes

17-Feb-2006
• Quick release to get many changes out there - but this release has been less tested then I would like for a .3
release.
• Allow access to non text controls using the closest Text control. This closest text control will normally be the
static/label associated with the control. For example in Notepad, Format->Font dialog, the 1st combobox can be
refered to as “FontComboBox” rather than “ComboBox1”
• Added a new control wrapper - PopupMenuWrapper for context menu’s You can now work easily with
context menu’s e.g.
app.Notepad.Edit.RightClick()
# need to use MenuClick rather then MenuSelect
app.PopupMenu.MenuClick("Select All")
app.Notepad.Edit.RightClick()
app.PopupMenu.MenuClick("Copy")

I could think of merging the RightClick() and MenuSelect() into one method
ContextMenuSelect() if that makes sense to most people.
• Added Support for Up-Down controls
• Not all top level windows now have a FriendlyClassName of “Dialog”. I changed this because it made it hard
to get windows of a particular class. For example the main Notepad window has a class name of “Notepad”.
This was primarily implemented due to work I did getting the System Tray.
• Renamed StatusBarWrapper.PartWidths() to PartRightEdges() as this is more correct for what
it returns.
• Changed HwndWrapper.Text() and SetText() to WindowText() and SetWindowText() respectively to try and
make it clearer that it is the text returned by GetWindowText and not the text that is visible on the control.
This change also suggested that EditWrapper.SetText() be changed to SetEditText() (though this is not a hard
requirement EditWrapper.SetText() still exists - but may be deprecated.
• Added ClickInput, DoubleClickInput, RightClickInput, PressMouseInput ReleaseMouseInput to HwndWrapper
- these use SendInput rather then WM_LBUTTONDOWN, WM_RBUTTONUP, etc used by Click, DoubleClick
etc.
I also added a MenuClick method that allows you to click on menu items. This means you can now ‘physically’
drop menus down.

10.28. 0.2.1 Small Release number - big changes 59


pywinauto Documentation, Release 0.6.8

• Some further working with tooltips that need to be cleaned up.


• Fixed a bug where coordinates passed to any of the Click operations had the X and Y coordinates swapped.
• Added new MenuItem and Menu classes that are to the most part hidden but you can get a menu item by doing
app.Notepad.MenuItem("View")
app.Notepad.MenuItem("View->Status Bar")

MenuItems have various actions so for example you can use MenuItem.IsChecked() to check if the menu
item is checked. Among other methods there are Click() and Enabled().
• Modified the ‘best match’ algorithm for finding controls. It now searches a couple of times, and tries to find the
best fit for the text passed to it. The idea here is to make it more “Select what I want - not that other thing that
looks a bit like what I want!”. It is possible this change could mean you need to use new identifiers in scripts -
but in general very little modification should be necessary.
There was also a change to the algorithm that looked for the closest text control. It missed some obvious controls
in the previous implementation. It also had a bug for controls above the control rather than to the left.
• Added a new example scripts SaveFromInternetExplorer.py and SaveFromFirefox.py which show automating
downloading of a page from either of these browsers.
• Added yet more unit tests, there are now a total of 134 tests.

10.29 0.2.0 Significant refactoring

06-Feb-2006
• Changed how windows are searched for (from application) This chage should not be a significant change for
users
• Started adding unit tests (and the have already uncovered bugs that been fixed). They also point to areas of
missing functionality that will be addded with future updates
• Changed from property access to Control attributes to function access If your code was accessing properties of
controls then this might be a significant change! The main reasons for doing this were due to the inheritability
of properties (or lack there-of!) and the additional scafolding that was required to define them all.
• Updated the DialogWrapper.MenuSelect() method to notify the parent that it needs to initialize the
menu’s before it retrieves the items
• Added functionality to associate ‘non-text’ controls with the ‘text’ control closest to them. This allows controls
to be referenced by:
app.dlg.<Nearby_text><Window_class>

e.g. to reference the “Footer” edit control in the Page Setup dialog you could use:
app.PageSetup.FooterEdit

• Added a MoveWindow method to HwndWrapper


• Did some more cleanup (fixing pylint warnings) but still not finished
• Added some better support for .NET controls (not to be considered final)

60 Chapter 10. Change Log


pywinauto Documentation, Release 0.6.8

10.30 0.1.3 Many changes, few visible

15-Jan-2006
• Wrote doc strings for all modules, classes and functions
• Ran pychecker and pylint and fixed some errors/warning
• changed
_connect, _start, _window, _control, _write

respectively to
connect_, start_, window_, connect_, write_

If you forget to change _window, _connect and _start then you will probably get the following error.
TypeError: '_DynamicAttributes' object is not callable

• pywinauto is now a package name - you need to import it or its modules


• Changes to the code to deal with pywinauto package name
• Fixed searching for windows if a Parent is passed in
• Added Index to retrieved MenuItem dictionary
• Added a check to ensure that a windows Handle is a valid window
• Refactored some of the methods in common_controls
• Refactored how FriendlyClassName is discovered (and still not really happy!

10.31 0.1.2 Add Readme and rollup various changes

15-Jan-2006
• Updated Readme (original readme was incorrect)
• Added clipboard module
• Fixed DrawOutline part of tests.__init__.print_bugs
• Added a NotifyParent to HwndWrapper
• Make sure that HwndWrapper.ref is initialized to None
• Refactored some methods of ComboBox and ListBox
• Updated Combo/ListBox selection methods
• Removed hardcoded paths from test_application.py
• Added section to save the document as UTF-8 in MinimalNotepadTest
• Fixed EscapeSpecials and UnEscapeSpecials in XMLHelpers
• Made sure that overly large bitmaps do not break XML writing

10.30. 0.1.3 Many changes, few visible 61


pywinauto Documentation, Release 0.6.8

10.32 0.1.1 Minor bug fix release

12-Jan-2006
• Fixed some minor bugs discovered after release

10.33 0.1.0 Initial Release

6-Jan-2006

62 Chapter 10. Change Log


CHAPTER 11

Source code reference

11.1 Basic User Input Modules

11.1.1 pywinauto.mouse

Cross-platform module to emulate mouse events like a real user


pywinauto.mouse.click(button=’left’, coords=(0, 0))
Click at the specified coordinates
pywinauto.mouse.double_click(button=’left’, coords=(0, 0))
Double click at the specified coordinates
pywinauto.mouse.move(coords=(0, 0))
Move the mouse
pywinauto.mouse.press(button=’left’, coords=(0, 0))
Press the mouse button
pywinauto.mouse.release(button=’left’, coords=(0, 0))
Release the mouse button
pywinauto.mouse.right_click(coords=(0, 0))
Right click at the specified coords
pywinauto.mouse.scroll(coords=(0, 0), wheel_dist=1)
Do mouse wheel
pywinauto.mouse.wheel_click(coords=(0, 0))
Middle mouse button click at the specified coords

11.1.2 pywinauto.keyboard

Keyboard input emulation module


Automate typing keys or individual key actions (viz. press and hold, release) to an active window by
calling send_keys method.
You can use any Unicode characters (on Windows) and some special keys listed below. The module is
also available on Linux.
Available key codes:

63
pywinauto Documentation, Release 0.6.8

{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}, {LWIN},
{VK_DOWN}, {VK_F17}, {VK_F16}, {VK_F15}, {VK_F14}

~ is a shorter alias for {ENTER}

Modifiers:
• ’+’: {VK_SHIFT}
• ’^’: {VK_CONTROL}
• ’%’: {VK_MENU} a.k.a. Alt key
Example how to use modifiers:
send_keys('^a^c') # select all (Ctrl+A) and copy to clipboard (Ctrl+C)
send_keys('+{INS}') # insert from clipboard (Shift+Ins)
send_keys('%{F4}') # close an active window with Alt+F4

Repetition count can be specified for special keys. {ENTER 2} says to press Enter twice.
Example which shows how to press and hold or release a key on the keyboard:
send_keys("{VK_SHIFT down}"
"pywinauto"
"{VK_SHIFT up}") # to type PYWINAUTO

send_keys("{h down}"
"{e down}"
"{h up}"
"{e up}"
"llo") # to type hello

Use curly brackers to escape modifiers and type reserved symbols as single keys:
send_keys('{^}a{^}c{%}') # type string "^a^c%" (Ctrl will not be pressed)
send_keys('{{}ENTER{}}') # type string "{ENTER}" without pressing Enter key

For Windows only, pywinauto defaults to sending a virtual key packet (VK_PACKET) for textual input.
For applications that do not handle VK_PACKET appropriately, the vk_packet option may be set to

64 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

False. In this case pywinauto will attempt to send the virtual key code of the requested key. This
option only affects the behavior of keys matching [-=[];’,./a-zA-Z0-9 ]. Note that upper and lower case
are included for a-z. Both reference the same virtual key for convenience.

11.2 Main User Modules

11.2.1 pywinauto.application module

The application module is the main one that users will use first.
When starting to automate an application you must initialize an instance of the Application class. Then you must
Application.start() that application or Application.connect() to a running instance of that applica-
tion.
Once you have an Application instance you can access dialogs in that application either by using one of the methods
below.
dlg = app.YourDialogTitle
dlg = app.child_window(title="your title", classname="your class", ...)
dlg = app['Your Dialog Title']

Similarly once you have a dialog you can get a control from that dialog in almost exactly the same ways.
ctrl = dlg.YourControlTitle
ctrl = dlg.child_window(title="Your control", classname="Button", ...)
ctrl = dlg["Your control"]

Note: For attribute access of controls and dialogs you do not have to have the title of the control exactly, it does a
best match of the available dialogs or controls.

See also:
pywinauto.findwindows.find_elements() for the keyword arguments that can be passed to both:
Application.window() and WindowSpecification.child_window()
exception pywinauto.application.AppNotConnected
Bases: Exception
Application has not been connected to a process yet
exception pywinauto.application.AppStartError
Bases: Exception
There was a problem starting the Application
class pywinauto.application.Application(backend=’win32’, datafilename=None, al-
low_magic_lookup=True)
Bases: object
Represents an application
__getattribute__(attr_name)
__getitem__(key)
Find the specified dialog of the application
GetMatchHistoryItem(index)
Should not be used - part of application data implementation

11.2. Main User Modules 65


pywinauto Documentation, Release 0.6.8

WriteAppData(filename)
Should not be used - part of application data implementation
active()
Return WindowSpecification for an active window of the application
connect(**kwargs)
Connect to an already running process
The action is performed according to only one of parameters
Parameters
• process – a process ID of the target
• handle – a window handle of the target
• path – a path used to launch the target
• timeout – a timeout for process start (relevant if path is specified)
See also:
pywinauto.findwindows.find_elements() - the keyword arguments that are also can be used
instead of process, handle or path
cpu_usage(interval=None)
Return CPU usage percent during specified number of seconds
is64bit()
Return True if running process is 64-bit
is_process_running()
Check that process is running.
Can be called before start/connect.
Return True if process is running otherwise - False.
kill(soft=False)
Try to close (optional) and kill the application
Dialogs may pop up asking to save data - but the application will be killed anyway - you will not be able
to click the buttons. This should only be used when it is OK to kill the process like you would do in task
manager.
start(cmd_line, timeout=None, retry_interval=None, create_new_console=False, wait_for_idle=True,
work_dir=None)
Start the application as specified by cmd_line
top_window()
Return WindowSpecification for a current top window of the application
wait_cpu_usage_lower(threshold=2.5, timeout=None, usage_interval=None)
Wait until process CPU usage percentage is less than the specified threshold
wait_for_process_exit(timeout=None, retry_interval=None)
Waits for process to exit until timeout reaches
Raises TimeoutError exception if timeout was reached
window(**kwargs)
Return a window of the application
You can specify the same parameters as findwindows.find_windows. It will add the process parameter to
ensure that the window is from the current process.

66 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

See pywinauto.findwindows.find_elements() for the full parameters description.


windows(**kwargs)
Return a list of wrapped top level windows of the application
pywinauto.application.AssertValidProcess(process_id)
Raise ProcessNotFound error if process_id is not a valid process id
exception pywinauto.application.ProcessNotFoundError
Bases: Exception
Could not find that process
class pywinauto.application.WindowSpecification(search_criteria, al-
low_magic_lookup=True)
Bases: object
A specification for finding a window or control
Windows are resolved when used. You can also wait for existance or non existance of a window
__getattribute__(attr_name)
Attribute access for this class
If we already have criteria for both dialog and control then resolve the control and return the requested
attribute.
If we have only criteria for the dialog but the attribute requested is an attribute of DialogWrapper then
resolve the dialog and return the requested attribute.
Otherwise delegate functionality to __getitem__() - which sets the appropriate criteria for the control.
__getitem__(key)
Allow access to dialogs/controls through item access
This allows:
app['DialogTitle']['ControlTextClass']

to be used to access dialogs and controls.


Both this and __getattribute__() use the rules outlined in the HowTo document.
WAIT_CRITERIA_MAP = {‘exists’: (‘exists’,), ‘visible’: (‘is_visible’,), ‘enabled’: (‘is_enabled’,), ‘ready’: (‘is_visible’, ‘is_e
child_window(**criteria)
Add criteria for a control
When this window specification is resolved it will be used to match against a control.
dump_tree(depth=None, filename=None)
Prints the ‘identifiers’
Prints identifiers for the control and for its descendants to a depth of depth (the whole subtree if None).

Note: The identifiers printed by this method have been made unique. So if you have 2 edit boxes, they
won’t both have “Edit” listed in their identifiers. In fact the first one can be referred to as “Edit”, “Edit0”,
“Edit1” and the 2nd should be referred to as “Edit2”.

exists(timeout=None, retry_interval=None)
Check if the window exists, return True if the control exists
Parameters

11.2. Main User Modules 67


pywinauto Documentation, Release 0.6.8

• timeout – the maximum amount of time to wait for the control to exists. Defaults to
Timings.exists_timeout
• retry_interval – The control is checked for existance this number of seconds.
Defaults to Timings.exists_retry
print_control_identifiers(depth=None, filename=None)
Prints the ‘identifiers’
Prints identifiers for the control and for its descendants to a depth of depth (the whole subtree if None).

Note: The identifiers printed by this method have been made unique. So if you have 2 edit boxes, they
won’t both have “Edit” listed in their identifiers. In fact the first one can be referred to as “Edit”, “Edit0”,
“Edit1” and the 2nd should be referred to as “Edit2”.

print_ctrl_ids(depth=None, filename=None)
Prints the ‘identifiers’
Prints identifiers for the control and for its descendants to a depth of depth (the whole subtree if None).

Note: The identifiers printed by this method have been made unique. So if you have 2 edit boxes, they
won’t both have “Edit” listed in their identifiers. In fact the first one can be referred to as “Edit”, “Edit0”,
“Edit1” and the 2nd should be referred to as “Edit2”.

wait(wait_for, timeout=None, retry_interval=None)


Wait for the window to be in a particular state/states.
Parameters
• wait_for – The state to wait for the window to be in. It can be any of the following
states, also you may combine the states by space key.
– ‘exists’ means that the window is a valid handle
– ‘visible’ means that the window is not hidden
– ‘enabled’ means that the window is not disabled
– ‘ready’ means that the window is visible and enabled
– ‘active’ means that the window is active
• timeout – Raise an pywinauto.timings.TimeoutError() if the win-
dow is not in the appropriate state after this number of seconds. Default:
pywinauto.timings.Timings.window_find_timeout.
• retry_interval – How long to sleep between each retry. Default:
pywinauto.timings.Timings.window_find_retry.
An example to wait until the dialog exists, is ready, enabled and visible:
self.Dlg.wait("exists enabled visible ready")

See also:
WindowSpecification.wait_not()
pywinauto.timings.TimeoutError()
wait_not(wait_for_not, timeout=None, retry_interval=None)
Wait for the window to not be in a particular state/states.

68 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

Parameters
• wait_for_not – The state to wait for the window to not be in. It can be any of the
following states, also you may combine the states by space key.
– ‘exists’ means that the window is a valid handle
– ‘visible’ means that the window is not hidden
– ‘enabled’ means that the window is not disabled
– ‘ready’ means that the window is visible and enabled
– ‘active’ means that the window is active
• timeout – Raise an pywinauto.timings.TimeoutError() if
the window is sill in the state after this number of seconds. Default:
pywinauto.timings.Timings.window_find_timeout.
• retry_interval – How long to sleep between each retry. Default:
pywinauto.timings.Timings.window_find_retry.
An example to wait until the dialog is not ready, enabled or visible:
self.Dlg.wait_not("enabled visible ready")

See also:
WindowSpecification.wait()
pywinauto.timings.TimeoutError()
window(**criteria)
Deprecated alias of child_window()
wrapper_object()
Allow the calling code to get the HwndWrapper object
pywinauto.application.assert_valid_process(process_id)
Raise ProcessNotFound error if process_id is not a valid process id
pywinauto.application.process_from_module(module)
Return the running process with path module
pywinauto.application.process_get_modules()
Return the list of processes as tuples (pid, exe_path)
pywinauto.application.process_module(process_id)
Return the string module name of this process

11.2.2 pywinauto.findbestmatch

Module to find the closest match of a string in a list


exception pywinauto.findbestmatch.MatchError(items=None, tofind=’‘)
A suitable match could not be found
class pywinauto.findbestmatch.UniqueDict
A dictionary subclass that handles making its keys unique
find_best_matches(search_text, clean=False, ignore_case=False)
Return the best matches for search_text in the items
•search_text the text to look for
•clean whether to clean non text characters out of the strings

11.2. Main User Modules 69


pywinauto Documentation, Release 0.6.8

•ignore_case compare strings case insensitively


pywinauto.findbestmatch.build_unique_dict(controls)
Build the disambiguated list of controls
Separated out to a different function so that we can get the control identifiers for printing.
pywinauto.findbestmatch.find_best_control_matches(search_text, controls)
Returns the control that is the the best match to search_text
This is slightly differnt from find_best_match in that it builds up the list of text items to search
through using information from each control. So for example for there is an OK, Button then the
following are all added to the search list: “OK”, “Button”, “OKButton”
But if there is a ListView (which do not have visible ‘text’) then it will just add “ListView”.
pywinauto.findbestmatch.find_best_match(search_text, item_texts, items,
limit_ratio=0.5)
Return the item that best matches the search_text
•search_text The text to search for
•item_texts The list of texts to search through
•items The list of items corresponding (1 to 1) to the list of texts to search through.
•limit_ratio How well the text has to match the best match. If the best match matches lower
then this then it is not considered a match and a MatchError is raised, (default = .5)
pywinauto.findbestmatch.get_control_names(control, allcontrols, textcontrols)
Returns a list of names for this control
pywinauto.findbestmatch.get_non_text_control_name(ctrl, controls,
text_ctrls)
return the name for this control by finding the closest text control above and to its left
pywinauto.findbestmatch.is_above_or_to_left(ref_control, other_ctrl)
Return true if the other_ctrl is above or to the left of ref_control

11.2.3 pywinauto.findwindows

Provides functions for iterating and finding windows/elements


exception pywinauto.findwindows.ElementAmbiguousError
There was more then one element that matched
exception pywinauto.findwindows.ElementNotFoundError
No element could be found
exception pywinauto.findwindows.WindowAmbiguousError
There was more then one window that matched
exception pywinauto.findwindows.WindowNotFoundError
No window could be found
pywinauto.findwindows.enum_windows()
Return a list of handles of all the top level windows
pywinauto.findwindows.find_element(**kwargs)
Call find_elements and ensure that only one element is returned
Calls find_elements with exactly the same arguments as it is called with so please see
find_elements() for the full parameters description.

70 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

pywinauto.findwindows.find_elements(class_name=None, class_name_re=None,
parent=None, process=None, title=None,
title_re=None, top_level_only=True, vis-
ible_only=True, enabled_only=False,
best_match=None, handle=None,
ctrl_index=None, found_index=None,
predicate_func=None, active_only=False,
control_id=None, control_type=None,
auto_id=None, framework_id=None, back-
end=None, depth=None)
Find elements based on criteria passed in
WARNING! Direct usage of this function is not recommended! It’s a very low level API. Better use
Application and WindowSpecification objects described in the Getting Started Guide.
Possible values are:
•class_name Elements with this window class
•class_name_re Elements whose class matches this regular expression
•parent Elements that are children of this
•process Elements running in this process
•title Elements with this text
•title_re Elements whose text matches this regular expression
•top_level_only Top level elements only (default=**True**)
•visible_only Visible elements only (default=**True**)
•enabled_only Enabled elements only (default=False)
•best_match Elements with a title similar to this
•handle The handle of the element to return
•ctrl_index The index of the child element to return
•found_index The index of the filtered out child element to return
•predicate_func A user provided hook for a custom element validation
•active_only Active elements only (default=False)
•control_id Elements with this control id
•control_type Elements with this control type (string; for UIAutomation elements)
•auto_id Elements with this automation id (for UIAutomation elements)
•framework_id Elements with this framework id (for UIAutomation elements)
•backend Back-end name to use while searching (default=None means current active backend)
pywinauto.findwindows.find_window(**kwargs)
Call find_elements and ensure that only handle of one element is returned
Calls find_elements with exactly the same arguments as it is called with so please see
find_elements() for the full parameters description.
pywinauto.findwindows.find_windows(**kwargs)
Find elements based on criteria passed in and return list of their handles

11.2. Main User Modules 71


pywinauto Documentation, Release 0.6.8

Calls find_elements with exactly the same arguments as it is called with so please see
find_elements() for the full parameters description.

11.2.4 pywinauto.timings

Global timing settings for all of pywinauto


This module has one object that should be used for all timing adjustments:
• timings.Timings
There are a couple of predefined settings:
• timings.Timings.fast()
• timings.Timings.defaults()
• timings.Timings.slow()
The Following are the individual timing settings that can be adjusted:
• window_find_timeout (default 5)
• window_find_retry (default .09)
• app_start_timeout (default 10)
• app_start_retry (default .90)
• app_connect_timeout (default 5.)
• app_connect_retry (default .1)
• cpu_usage_interval (default .5)
• cpu_usage_wait_timeout (default 20)
• exists_timeout (default .5)
• exists_retry (default .3)
• after_click_wait (default .09)
• after_clickinput_wait (default .09)
• after_menu_wait (default .1)
• after_sendkeys_key_wait (default .01)
• after_button_click_wait (default 0)
• before_closeclick_wait (default .1)
• closeclick_retry (default .05)
• closeclick_dialog_close_wait (default 2)
• after_closeclick_wait (default .2)
• after_windowclose_timeout (default 2)
• after_windowclose_retry (default .5)
• after_setfocus_wait (default .06)
• setfocus_timeout (default 2)
• setfocus_retry (default .1)

72 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

• after_setcursorpos_wait (default .01)


• sendmessagetimeout_timeout (default .01)
• after_tabselect_wait (default .05)
• after_listviewselect_wait (default .01)
• after_listviewcheck_wait default(.001)
• listviewitemcontrol_timeout default(1.5)
• after_treeviewselect_wait default(.1)
• after_toobarpressbutton_wait default(.01)
• after_updownchange_wait default(.1)
• after_movewindow_wait default(0)
• after_buttoncheck_wait default(0)
• after_comboboxselect_wait default(.001)
• after_listboxselect_wait default(0)
• after_listboxfocuschange_wait default(0)
• after_editsetedittext_wait default(0)
• after_editselect_wait default(.02)
• drag_n_drop_move_mouse_wait default(.1)
• before_drag_wait default(.2)
• before_drop_wait default(.1)
• after_drag_n_drop_wait default(.1)
• scroll_step_wait default(.1)
class pywinauto.timings.TimeConfig
Central storage and manipulation of timing values
Defaults(*args, **kwargs)
Fast(*args, **kwargs)
Slow(*args, **kwargs)
defaults()
Set all timings to the default time
fast()
Set fast timing values
Currently this changes the timing in the following ways: timeouts = 1 second waits = 0 seconds
retries = .001 seconds (minimum!)
(if existing times are faster then keep existing times)
slow()
Set slow timing values
Currently this changes the timing in the following ways: timeouts = default timeouts * 10 waits
= default waits * 3 retries = default retries * 3
(if existing times are slower then keep existing times)

11.2. Main User Modules 73


pywinauto Documentation, Release 0.6.8

exception pywinauto.timings.TimeoutError
pywinauto.timings.always_wait_until(timeout, retry_interval, value=True,
op=<built-in function eq>)
Decorator to call wait_until(...) every time for a decorated function/method
pywinauto.timings.always_wait_until_passes(timeout, retry_interval, excep-
tions=<class ‘Exception’>)
Decorator to call wait_until_passes(...) every time for a decorated function/method
pywinauto.timings.timestamp()
Get a precise timestamp
pywinauto.timings.wait_until(timeout, retry_interval, func, value=True, op=<built-in
function eq>, *args, **kwargs)
Wait until op(function(*args, **kwargs), value) is True or until timeout expires
•timeout how long the function will try the function
•retry_interval how long to wait between retries
•func the function that will be executed
•value the value to be compared against (defaults to True)
•op the comparison function (defaults to equality)
•args optional arguments to be passed to func when called
•kwargs optional keyword arguments to be passed to func when called
Returns the return value of the function If the operation times out then the return value of the the
function is in the ‘function_value’ attribute of the raised exception.
e.g.
try:
# wait a maximum of 10.5 seconds for the
# the objects item_count() method to return 10
# in increments of .5 of a second
wait_until(10.5, .5, self.item_count, 10)
except TimeoutError as e:
print("timed out")

pywinauto.timings.wait_until_passes(timeout, retry_interval, func, excep-


tions=<class ‘Exception’>, *args,
**kwargs)
Wait until func(*args, **kwargs) does not raise one of the exceptions
•timeout how long the function will try the function
•retry_interval how long to wait between retries
•func the function that will be executed
•exceptions list of exceptions to test against (default: Exception)
•args optional arguments to be passed to func when called
•kwargs optional keyword arguments to be passed to func when called
Returns the return value of the function If the operation times out then the original exception raised
is in the ‘original_exception’ attribute of the raised exception.
e.g.

74 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

try:
# wait a maximum of 10.5 seconds for the
# window to be found in increments of .5 of a second.
# P.int a message and re-raise the original exception if never found.
wait_until_passes(10.5, .5, self.Exists, (ElementNotFoundError))
except TimeoutError as e:
print("timed out")
raise e.

11.3 Specific Functionality

11.3.1 pywinauto.clipboard

Some clipboard wrapping functions - more to be added later


pywinauto.clipboard.EmptyClipboard()
pywinauto.clipboard.GetClipboardFormats()
Get a list of the formats currently in the clipboard
pywinauto.clipboard.GetData(format_id=<MagicMock
name=’mock.CF_UNICODETEXT’
id=‘140198715111016’>)
Return the data from the clipboard in the requested format
pywinauto.clipboard.GetFormatName(format_id)
Get the string name for a format value

11.3.2 pywinauto.win32_hooks

Windows global hooks in pure Python


The implementation uses foreign function interface (FFI) provided by standard Python module ctypes
and inspired by pyHook, pyhooked and other similar modules (the code was re-written from scratch). It
tends to be a superset of pyHook but in pure Python only so it doesn’t require compilation.
Current set of hooks implemented:
• WH_MOUSE_LL
• WH_KEYBOARD_LL
More detailed documentation about Windows hooks can be found in MSDN: https://msdn.microsoft.com/
en-us/library/windows/desktop/ms632589.aspx
This module can be used as a stand alone or along with pywinauto. The fork of this code (at some
moment) was used in standalone library pyhooked 0.8 maintained by Ethan Smith.
class pywinauto.win32_hooks.Hook
Hook for low level keyboard and mouse events
hook(keyboard=True, mouse=False)
Hook mouse and/or keyboard events
is_hooked()
Verify if any of hooks are active

11.3. Specific Functionality 75


pywinauto Documentation, Release 0.6.8

listen()
Listen for events
stop()
Stop the listening loop
unhook_keyboard()
Unhook keyboard events
unhook_mouse()
Unhook mouse events
class pywinauto.win32_hooks.KeyboardEvent(current_key=None, event_type=None,
pressed_key=None)
Created when a keyboard event happened
class pywinauto.win32_hooks.MouseEvent(current_key=None, event_type=None,
mouse_x=0, mouse_y=0)
Created when a mouse event happened

11.4 Controls Reference

11.4.1 pywinauto.base_wrapper

Base class for all wrappers in all backends


class pywinauto.base_wrapper.BaseMeta
Abstract metaclass for Wrapper objects
static find_wrapper(element)
Abstract static method to find an appropriate wrapper
class pywinauto.base_wrapper.BaseWrapper(element_info, active_backend)
Abstract wrapper for elements.
All other wrappers are derived from this.
can_be_label = False
capture_as_image(rect=None)
Return a PIL image of the control.
See PIL documentation to know what you can do with the resulting image.
children(**kwargs)
Return the children of this element as a list
It returns a list of BaseWrapper (or subclass) instances. An empty list is returned if there are no
children.
class_name()
Return the class name of the elenemt
click_input(button=’left’, coords=(None, None), button_down=True, button_up=True,
double=False, wheel_dist=0, use_log=True, pressed=’‘, absolute=False,
key_down=True, key_up=True)
Click at the specified coordinates
•button The mouse button to click. One of ‘left’, ‘right’, ‘middle’ or ‘x’ (Default: ‘left’,
‘move’ is a special case)
•coords The coordinates to click at.(Default: the center of the control)

76 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

•double Whether to perform a double click or not (Default: False)


•wheel_dist The distance to move the mouse wheel (default: 0)
NOTES: This is different from click method in that it requires the control to be visible on the
screen but performs a more realistic ‘click’ simulation.
This method is also vulnerable if the mouse is moved by the user as that could easily move
the mouse off the control before the click_input has finished.
client_to_screen(client_point)
Maps point from client to screen coordinates
control_count()
Return the number of children of this control
control_id()
Return the ID of the element
Only controls have a valid ID - dialogs usually have no ID assigned.
The ID usually identified the control in the window - but there can be duplicate ID’s for example
lables in a dialog may have duplicate ID’s.
descendants(**kwargs)
Return the descendants of this element as a list
It returns a list of BaseWrapper (or subclass) instances. An empty list is returned if there are no
descendants.
double_click_input(button=’left’, coords=(None, None))
Double click at the specified coordinates
drag_mouse_input(dst=(0, 0), src=None, button=’left’, pressed=’‘, absolute=True)
Click on src, drag it and drop on dst
•dst is a destination wrapper object or just coordinates.
•src is a source wrapper object or coordinates. If src is None the self is used as a source
object.
•button is a mouse button to hold during the drag. It can be “left”, “right”, “middle” or “x”
•pressed is a key on the keyboard to press during the drag.
•absolute specifies whether to use absolute coordinates for the mouse pointer locations
draw_outline(colour=’green’, thickness=2, fill=<MagicMock
name=’mock.win32defines.BS_NULL’ id=‘140198720113576’>,
rect=None)
Draw an outline around the window.
•colour can be either an integer or one of ‘red’, ‘green’, ‘blue’ (default ‘green’)
•thickness thickness of rectangle (default 2)
•fill how to fill in the rectangle (default BS_NULL)
•rect the coordinates of the rectangle to draw (defaults to the rectangle of the control)
element_info
Read-only property to get ElementInfo object
friendly_class_name()
Return the friendly class name for the control
This differs from the class of the control in some cases. class_name() is the actual ‘Registered’
element class of the control while friendly_class_name() is hopefully something that will make
more sense to the user.
For example Checkboxes are implemented as Buttons - so the class of a CheckBox is “Button”
- but the friendly class is “CheckBox”

11.4. Controls Reference 77


pywinauto Documentation, Release 0.6.8

friendlyclassname = None
from_point(x, y)
Get wrapper object for element at specified screen coordinates (x, y)
get_properties()
Return the properties of the control as a dictionary.
has_title = True
is_child(parent)
Return True if this element is a child of ‘parent’.
An element is a child of another element when it is a direct of the other element. An element is
a direct descendant of a given element if the parent element is the the chain of parent elements
for the child element.
is_dialog()
Return True if the control is a top level window
is_enabled()
Whether the element is enabled or not
Checks that both the top level parent (probably dialog) that owns this element and the element
itself are both enabled.
If you want to wait for an element to become enabled (or wait for it to become disabled) use
Application.wait(’visible’) or Application.wait_not(’visible’).
If you want to raise an exception immediately if an element is not enabled then you can use the
BaseWrapper.verify_enabled(). BaseWrapper.VerifyReady() raises if the window is not both
visible and enabled.
is_visible()
Whether the element is visible or not
Checks that both the top level parent (probably dialog) that owns this element and the element
itself are both visible.
If you want to wait for an element to become visible (or wait for it to become hidden) use
Application.wait(’visible’) or Application.wait_not(’visible’).
If you want to raise an exception immediately if an element is not visible then you can use
the BaseWrapper.verify_visible(). BaseWrapper.verify_actionable() raises if the element is not
both visible and enabled.
iter_children(**kwargs)
Iterate over the children of this element
It returns a generator of BaseWrapper (or subclass) instances.
iter_descendants(**kwargs)
Iterate over the descendants of this element
It returns a generator of BaseWrapper (or subclass) instances.
move_mouse_input(coords=(0, 0), pressed=’‘, absolute=True)
Move the mouse
parent()
Return the parent of this element
Note that the parent of a control is not necesarily a dialog or other main window. A group box
may be the parent of some radio buttons for example.

78 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

To get the main (or top level) window then use BaseWrapper.top_level_parent().
press_mouse_input(button=’left’, coords=(None, None), pressed=’‘, absolute=True,
key_down=True, key_up=True)
Press a mouse button using SendInput
process_id()
Return the ID of process that owns this window
rectangle()
Return the rectangle of element
The rectangle() is the rectangle of the element on the screen. Coordinates are given from the
top left of the screen.
This method returns a RECT structure, Which has attributes - top, left, right, bottom. and has
methods width() and height(). See win32structures.RECT for more information.
release_mouse_input(button=’left’, coords=(None, None), pressed=’‘, absolute=True,
key_down=True, key_up=True)
Release the mouse button
right_click_input(coords=(None, None))
Right click at the specified coords
root()
Return wrapper for root element (desktop)
set_focus()
Set the focus to this element
texts()
Return the text for each item of this control
It is a list of strings for the control. It is frequently overridden to extract all strings from a
control with multiple items.
It is always a list with one or more strings:
•The first element is the window text of the control
•Subsequent elements contain the text of any items of the control (e.g. items in a list-
box/combobox, tabs in a tabcontrol)
top_from_point(x, y)
Get wrapper object for top level element at specified screen coordinates (x, y)
top_level_parent()
Return the top level window of this control
The TopLevel parent is different from the parent in that the parent is the element that owns this
element - but it may not be a dialog/main window. For example most Comboboxes have an
Edit. The ComboBox is the parent of the Edit control.
This will always return a valid window element (if the control has no top level parent then the
control itself is returned - as it is a top level window already!)
type_keys(keys, pause=None, with_spaces=False, with_tabs=False, with_newlines=False,
turn_off_numlock=True, set_foreground=True, vk_packet=True)
Type keys to the element using keyboard.send_keys
This uses the re-written keyboard python module where you can find documentation on what to
use for the keys.
verify_actionable()
Verify that the element is both visible and enabled

11.4. Controls Reference 79


pywinauto Documentation, Release 0.6.8

Raise either ElementNotEnalbed or ElementNotVisible if not enabled or visible respectively.


verify_enabled()
Verify that the element is enabled
Check first if the element’s parent is enabled (skip if no parent), then check if element itself is
enabled.
verify_visible()
Verify that the element is visible
Check first if the element’s parent is visible. (skip if no parent), then check if element itself is
visible.
wait_for_idle()
Backend specific function to wait for idle state of a thread or a window
was_maximized()
Indicate whether the window was maximized before minimizing or not
wheel_mouse_input(coords=(None, None), wheel_dist=1, pressed=’‘)
Do mouse wheel
window_text()
Window text of the element
Quite a few contorls have other text that is visible, for example Edit controls usually have an
empty string for window_text but still have text displayed in the edit window.
windowclasses = []
writable_props
Build the list of the default properties to be written.
Derived classes may override or extend this list depending on how much control they need.
exception pywinauto.base_wrapper.ElementNotEnabled
Raised when an element is not enabled
exception pywinauto.base_wrapper.ElementNotVisible
Raised when an element is not visible
exception pywinauto.base_wrapper.InvalidElement
Raises when an invalid element is passed
pywinauto.base_wrapper.remove_non_alphanumeric_symbols(s)
Make text usable for attribute name

11.4.2 pywinauto.controls.hwndwrapper

Basic wrapping of Windows controls


exception pywinauto.controls.hwndwrapper.ControlNotEnabled
Bases: RuntimeError
Raised when a control is not enabled
exception pywinauto.controls.hwndwrapper.ControlNotVisible
Bases: RuntimeError
Raised when a control is not visible

80 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

class pywinauto.controls.hwndwrapper.DialogWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Wrap a dialog
ClientAreaRect(*args, **kwargs)
HideFromTaskbar(*args, **kwargs)
IsInTaskbar(*args, **kwargs)
RunTests(*args, **kwargs)
ShowInTaskbar(*args, **kwargs)
WriteToXML(*args, **kwargs)
can_be_label = True
client_area_rect()
Return the client area rectangle
From MSDN: The client area of a control is the bounds of the control, minus the nonclient
elements such as scroll bars, borders, title bars, and menus.
force_close()
Close the dialog forcefully using WM_QUERYENDSESSION and return the result
Window has let us know that it doesn’t want to die - so we abort this means that the app is not
hung - but knows it doesn’t want to close yet - e.g. it is asking the user if they want to save.
friendlyclassname = ‘Dialog’
hide_from_taskbar()
Hide the dialog from the Windows taskbar
is_in_taskbar()
Check whether the dialog is shown in the Windows taskbar
Thanks to David Heffernan for the idea: http://stackoverflow.com/questions/30933219/
hide-window-from-taskbar-without-using-ws-ex-toolwindow A window is represented in the
taskbar if: It has no owner and it does not have the WS_EX_TOOLWINDOW extended style,
or it has the WS_EX_APPWINDOW extended style.
run_tests(tests_to_run=None, ref_controls=None)
Run the tests on dialog
show_in_taskbar()
Show the dialog in the Windows taskbar
write_to_xml(filename)
Write the dialog an XML file (requires elementtree)
class pywinauto.controls.hwndwrapper.HwndMeta(name, bases, attrs)
Bases: pywinauto.base_wrapper.BaseMeta
Metaclass for HwndWrapper objects
static find_wrapper(element)
Find the correct wrapper for this native element
class pywinauto.controls.hwndwrapper.HwndWrapper(element_info)
Bases: pywinauto.base_wrapper.BaseWrapper
Default wrapper for controls.

11.4. Controls Reference 81


pywinauto Documentation, Release 0.6.8

All other wrappers are derived from this.


This class wraps a lot of functionality of underlying windows API features for working with win-
dows.
Most of the methods apply to every single window type. For example you can click() on any window.
Most of the methods of this class are simple wrappers around API calls and as such they try do the
simplest thing possible.
An HwndWrapper object can be passed directly to a ctypes wrapped C function - and it will get
converted to a Long with the value of it’s handle (see ctypes, _as_parameter_).
automation_id()
Return the .NET name of the control
click(button=’left’, pressed=’‘, coords=(0, 0), double=False, absolute=False)
Simulates a mouse click on the control
This method sends WM_* messages to the control, to do a more ‘realistic’ mouse click use
click_input() which uses mouse_event() API to perform the click.
This method does not require that the control be visible on the screen (i.e. it can be hidden
beneath another window and it will still work).
client_rect()
Returns the client rectangle of window
The client rectangle is the window rectangle minus any borders that are not available to the
control for drawing.
Both top and left are always 0 for this method.
This method returns a RECT structure, Which has attributes - top, left, right, bottom. and has
methods width() and height(). See win32structures.RECT for more information.
client_rects()
Return the client rect for each item in this control
It is a list of rectangles for the control. It is frequently over-ridden to extract all rectangles from
a control with multiple items.
It is always a list with one or more rectangles:
•First elemtent is the client rectangle of the control
•Subsequent elements contain the client rectangle of any items of the control (e.g. items in
a listbox/combobox, tabs in a tabcontrol)
close(wait_time=0)
Close the window
Code modified from http://msdn.microsoft.com/msdnmag/issues/02/08/CQA/
close_alt_f4()
Close the window by pressing Alt+F4 keys.
close_click(button=’left’, pressed=’‘, coords=(0, 0), double=False)
Perform a click action that should make the window go away
The only difference from click is that there are extra delays before and after the click action.
context_help_id()
Return the Context Help ID of the window
control_type()
Return the .NET type of the control

82 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

debug_message(text)
Write some debug text over the window
double_click(button=’left’, pressed=’‘, coords=(0, 0))
Perform a double click action
drag_mouse(button=’left’, press_coords=(0, 0), release_coords=(0, 0), pressed=’‘)
Drag the mouse
exstyle()
Returns the Extended style of window
Return value is a long.
Combination of WS_* and specific control specific styles. See HwndWrapper.has_style() to
easily check if the window has a particular style.
font()
Return the font of the window
The font of the window is used to draw the text of that window. It is a structure which has
attributes for font name, height, width etc.
See win32structures.LOGFONTW for more information.
fonts()
Return the font for each item in this control
It is a list of fonts for the control. It is frequently over-ridden to extract all fonts from a control
with multiple items.
It is always a list with one or more fonts:
•First elemtent is the control font
•Subsequent elements contain the font of any items of the control (e.g. items in a list-
box/combobox, tabs in a tabcontrol)
full_control_type()
Return the .NET type of the control (full, uncut)
get_active()
Return a handle to the active window within the process
get_focus()
Return the control in the process of this window that has the Focus
get_show_state()
Get the show state and Maximized/minimzed/restored state
Returns a value that is a union of the following
•SW_HIDE the window is hidden.
•SW_MAXIMIZE the window is maximized
•SW_MINIMIZE the window is minimized
•SW_RESTORE the window is in the ‘restored’ state (neither minimized or maximized)
•SW_SHOW The window is not hidden
get_toolbar()
Get the first child toolbar if it exists
handle = None
has_exstyle(exstyle)
Return True if the control has the specified extended style

11.4. Controls Reference 83


pywinauto Documentation, Release 0.6.8

has_focus()
Check the window is in focus (foreground)
has_keyboard_focus()
Check the keyboard focus on this control.
has_style(style)
Return True if the control has the specified style
is_active()
Whether the window is active or not
is_dialog()
Return true if the control is a top level window
is_maximized()
Indicate whether the window is maximized or not
is_minimized()
Indicate whether the window is minimized or not
is_normal()
Indicate whether the window is normal (i.e. not minimized and not maximized)
is_unicode()
Whether the window is unicode or not
A window is Unicode if it was registered by the Wide char version of RegisterClass(Ex).
maximize()
Maximize the window
menu()
Return the menu of the control
menu_item(path, exact=False)
Return the menu item specified by path
Path can be a string in the form “MenuItem->MenuItem->MenuItem...” where each MenuItem
is the text of an item at that level of the menu. E.g.

File->Export->ExportAsPNG

spaces are not important so you could also have written...

File -> Export -> Export As PNG

menu_items()
Return the menu items for the dialog
If there are no menu items then return an empty list
menu_select(path, exact=False)
Find a menu item specified by the path
The full path syntax is specified in: controls.menuwrapper.Menu.get_menu_path()
minimize()
Minimize the window
move_mouse(coords=(0, 0), pressed=’‘, absolute=False)
Move the mouse by WM_MOUSEMOVE

84 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

move_window(x=None, y=None, width=None, height=None, repaint=True)


Move the window to the new coordinates
•x Specifies the new left position of the window. Defaults to the current left position of the
window.
•y Specifies the new top position of the window. Defaults to the current top position of the
window.
•width Specifies the new width of the window. Defaults to the current width of the window.
•height Specifies the new height of the window. Default to the current height of the window.
•repaint Whether the window should be repainted or not. Defaults to True
notify_parent(message, controlID=None)
Send the notification message to parent of this control
owner()
Return the owner window for the window if it exists
Returns None if there is no owner.
popup_window()
Return owned enabled Popup window wrapper if shown.
If there is no enabled popups at that time, it returns self. See MSDN reference: https://msdn.
microsoft.com/en-us/library/windows/desktop/ms633515.aspx
Please do not use in production code yet - not tested fully
post_command(commandID)
post_message(message, wparam=0, lparam=0)
Post a message to the control message queue and return
press_mouse(button=’left’, coords=(0, 0), pressed=’‘)
Press the mouse button
release_mouse(button=’left’, coords=(0, 0), pressed=’‘)
Release the mouse button
restore()
Restore the window to its previous state (normal or maximized)
right_click(pressed=’‘, coords=(0, 0))
Perform a right click action
scroll(direction, amount, count=1, retry_interval=None)
Ask the control to scroll itself
direction can be any of “up”, “down”, “left”, “right” amount can be one of “line”, “page”,
“end” count (optional) the number of times to scroll
send_chars(chars, with_spaces=True, with_tabs=True, with_newlines=True)
Silently send a character string to the control in an inactive window
If a virtual key with no corresponding character is encountered (e.g. VK_LEFT, VK_DELETE),
a KeySequenceError is raised. Consider using the method send_keystrokes for such input.
send_command(commandID)
send_keystrokes(keystrokes, with_spaces=True, with_tabs=True, with_newlines=True)
Silently send keystrokes to the control in an inactive window
It parses modifiers Shift(+), Control(^), Menu(%) and Sequences like “{TAB}”, “{ENTER}”
For more information about Sequences and Modifiers navigate to module keyboard

11.4. Controls Reference 85


pywinauto Documentation, Release 0.6.8

Due to the fact that each application handles input differently and this method is meant to be
used on inactive windows, it may work only partially depending on the target app. If the window
being inactive is not essential, use the robust type_keys method.
send_message(message, wparam=0, lparam=0)
Send a message to the control and wait for it to return
send_message_timeout(message, wparam=0, lparam=0, time-
out=None, timeoutflags=<MagicMock
name=’mock.win32defines.SMTO_NORMAL’
id=‘140198718303984’>)
Send a message to the control and wait for it to return or to timeout
If no timeout is given then a default timeout of .01 of a second will be used.
set_application_data(appdata)
Application data is data from a previous run of the software
It is essential for running scripts written for one spoke language on a different spoken language
set_focus()
Set the focus to this control.
Bring the window to the foreground first. The system restricts which processes can set the
foreground window (https://msdn.microsoft.com/en-us/library/windows/desktop/ms633539(v=
vs.85).aspx) so the mouse cursor is removed from the screen to prevent any side effects.
set_keyboard_focus()
Set the keyboard focus to this control.
set_transparency(alpha=120)
Set the window transparency from 0 to 255 by alpha attribute
set_window_text(text, append=False)
Set the text of the window
style()
Returns the style of window
Return value is a long.
Combination of WS_* and specific control specific styles. See HwndWrapper.has_style() to
easily check if the window has a particular style.
user_data()
Extra data associted with the window
This value is a long value that has been associated with the window and rarely has useful data
(or at least data that you know the use of).
wait_for_idle()
Backend specific function to wait for idle state of a thread or a window
writable_props
Extend default properties list.
exception pywinauto.controls.hwndwrapper.InvalidWindowHandle(hwnd)
Bases: RuntimeError
Raised when an invalid handle is passed to HwndWrapper
pywinauto.controls.hwndwrapper.get_dialog_props_from_handle(hwnd)
Get the properties of all the controls as a list of dictionaries

86 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

11.4.3 pywinauto.controls.menuwrapper

Wrapper around Menu’s and Menu items


These wrappers allow you to work easily with menu items. You can select or click on items and check if
they are checked or unchecked.
class pywinauto.controls.menuwrapper.Menu(owner_ctrl, menuhan-
dle, is_main_menu=True,
owner_item=None)
Bases: object
A simple wrapper around a menu handle
A menu supports methods for querying the menu and getting it’s menu items.
get_menu_path(path, path_items=None, appdata=None, exact=False)
Walk the items in this menu to find the item specified by a path
The path is specified by a list of items separated by ‘->’. Each item can be either a string (can
include spaces) e.g. “Save As” or a zero based index of the item to return prefaced by # e.g. #1
or an ID of the item prefaced by $ specifier.
These can be mixed as necessary. For example:
• “#0 -> Save As”,
• “$23453 -> Save As”,
• “Tools -> #0 -> Configure”
Text matching is done using a ‘best match’ fuzzy algorithm, so you don’t have to add all punctu-
ation, ellipses, etc. ID matching is performed against wID field of MENUITEMINFO structure
(https://msdn.microsoft.com/en-us/library/windows/desktop/ms647578(v=vs.85).aspx)
get_properties()
Return the properties for the menu as a list of dictionaries
This method is actually recursive. It calls get_properties() for each of the items. If the item has
a sub menu it will call this get_properties to get the sub menu items.
item(index, exact=False)
Return a specific menu item
•index is the 0 based index or text of the menu item you want.
•exact is True means exact matching for item text, False means best matching.
item_count()
Return the count of items in this menu
items()
Return a list of all the items in this menu
exception pywinauto.controls.menuwrapper.MenuInaccessible
Bases: RuntimeError
Raised when a menu has handle but inaccessible.
class pywinauto.controls.menuwrapper.MenuInfo
Bases: object
A holder for Menu Info
class pywinauto.controls.menuwrapper.MenuItem(ctrl, menu, index,
on_main_menu=False)
Bases: object
Wrap a menu item

11.4. Controls Reference 87


pywinauto Documentation, Release 0.6.8

click()
Select the menu item
This will send a message to the parent window that the item was picked.
click_input()
Click on the menu item in a more realistic way
If the menu is open it will click with the mouse event on the item. If the menu is not open each
of it’s parent’s will be opened until the item is visible.
friendly_class_name()
Return friendly class name
get_properties()
Return the properties for the item as a dict
If this item opens a sub menu then call Menu.get_properties() to return the list of items in the
sub menu. This is avialable under the ‘menu_items’ key.
index()
Return the index of this menu item
is_checked()
Return True if the item is checked.
is_enabled()
Return True if the item is enabled.
item_id()
Return the ID of this menu item
item_type()
Return the Type of this menu item
Main types are MF_STRING, MF_BITMAP, MF_SEPARATOR.
See https://msdn.microsoft.com/en-us/library/windows/desktop/ms647980.aspx for further in-
formation.
rectangle()
Get the rectangle of the menu item
select()
Select the menu item
This will send a message to the parent window that the item was picked.
state()
Return the state of this menu item
sub_menu()
Return the SubMenu or None if no submenu
text()
Return the text of this menu item
class pywinauto.controls.menuwrapper.MenuItemInfo
Bases: object
A holder for Menu Item Info
exception pywinauto.controls.menuwrapper.MenuItemNotEnabled
Bases: RuntimeError

88 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

Raised when a menu item is not enabled


pywinauto.controls.menuwrapper.ensure_accessible(method)
Decorator for Menu instance methods

11.4.4 pywinauto.controls.common_controls

Classes that wrap the Windows Common controls


class pywinauto.controls.common_controls._toolbar_button(index_, tb_handle)
Bases: object
Wrapper around Toolbar button (TBBUTTONINFO) items
click(button=’left’, pressed=’‘)
Click on the Toolbar button
click_input(button=’left’, double=False, wheel_dist=0, pressed=’‘)
Click on the Toolbar button
has_style(style)
Return True if the button has the specified style
is_checkable()
Return if the button can be checked
is_checked()
Return if the button is in the checked state
is_enabled()
Return if the button is in the pressed state
is_pressable()
Return if the button can be pressed
is_pressed()
Return if the button is in the pressed state
rectangle()
Get the rectangle of a button on the toolbar
state()
Return the state of the button
style()
Return the style of the button
text()
Return the text of the button
class pywinauto.controls.common_controls._treeview_element(elem, tv_handle)
Bases: object
Wrapper around TreeView items
children()
Return the direct children of this control
click(button=’left’, double=False, where=’text’, pressed=’‘)
Click on the treeview item
where can be any one of “text”, “icon”, “button”, “check” defaults to “text”

11.4. Controls Reference 89


pywinauto Documentation, Release 0.6.8

click_input(button=’left’, double=False, wheel_dist=0, where=’text’, pressed=’‘)


Click on the treeview item
where can be any one of “text”, “icon”, “button”, “check” defaults to “text”
client_rect(text_area_rect=True)
Return a rectangle of a text area of the item
If text_area_rect is set to False then it will return a rectangle for the whole item (usually left is equal to
0). Defaults to True - which returns just the rectangle of the text of the item
collapse()
Collapse the children of this tree view item
drop(button=’left’, pressed=’‘)
Drop at the item
ensure_visible()
Make sure that the TreeView item is visible
expand()
Expand the children of this tree view item
get_child(child_spec, exact=False)
Return the child item of this item
Accepts either a string or an index. If a string is passed then it returns the child item with the best match
for the string.
is_checked()
Return whether the TreeView item is checked or not
is_expanded()
Indicate that the TreeView item is selected or not
is_selected()
Indicate that the TreeView item is selected or not
item()
Return the item itself
next_item()
Return the next item
select()
Select the TreeView item
start_dragging(button=’left’, pressed=’‘)
Start dragging the item
state()
Return the state of the item
sub_elements()
Return the list of children of this control
text()
Return the text of the item
class pywinauto.controls.common_controls._listview_item(lv_ctrl, item_index,
subitem_index=0)
Bases: object
Wrapper around ListView items

90 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

check()
Check the ListView item
click(button=’left’, double=False, where=’text’, pressed=’‘)
Click on the list view item
where can be any one of “all”, “icon”, “text”, “select”, “check” defaults to “text”
click_input(button=’left’, double=False, wheel_dist=0, where=’text’, pressed=’‘)
Click on the list view item
where can be any one of “all”, “icon”, “text”, “select”, “check” defaults to “text”
deselect()
Mark the item as not selected
The ListView control must be enabled and visible before an Item can be selected otherwise an exception
is raised
ensure_visible()
Make sure that the ListView item is visible
image()
Return the image index of the item
indent()
Return the indent of the item
inplace_control(friendly_class_name=’‘)
Return the editor HwndWrapper of the item
Possible friendly_class_name values:
•"" Return the first appeared in-place control
•"friendlyclassname" Returns editor with particular friendlyclassname
is_checked()
Return whether the ListView item is checked or not
is_focused()
Return True if the item has the focus
is_selected()
Return True if the item is selected
item()
Return the item itself (LVITEM instance)
item_data()
Return the item data (dictionary)
rectangle(area=’all’)
Return the rectangle of the item.
Possible area values:
•"all" Returns the bounding rectangle of the entire item, including the icon and label.
•"icon" Returns the bounding rectangle of the icon or small icon.
•"text" Returns the bounding rectangle of the item text.
•"select" Returns the union of the “icon” and “text” rectangles, but excludes columns in report
view.

11.4. Controls Reference 91


pywinauto Documentation, Release 0.6.8

select()
Mark the item as selected
The ListView control must be enabled and visible before an Item can be selected otherwise an exception
is raised
state()
Return the state of the item
text()
Return the text of the item
uncheck()
Uncheck the ListView item
class pywinauto.controls.common_controls.AnimationWrapper(element_info)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows Animation common control
friendlyclassname = ‘Animation’
windowclasses = [’SysAnimate32’]
class pywinauto.controls.common_controls.CalendarWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows Calendar common control
calc_min_rectangle(left, top, right, bottom)
Calculates the minimum size that a rectangle needs to be to fit that number of calendars
count()
Get the calendars count
friendlyclassname = ‘Calendar’
get_border()
Get the calendar border
get_current_date()
Get the currently selected date
get_first_weekday()
Get is not in current locale and if so first day of the week
get_id()
Get type of calendar
get_month_delta()
Retrieves the scroll rate for a month calendar control
get_month_range(scope_of_range)
Retrieves date information that represents the high and low limits of a month calendar control’s display.
get_today()
Get today date
get_view()
Get the calendar view
has_title = False
hit_test(x, y)
Determines which portion of a month calendar control is at a given point on the screen

92 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

place_in_calendar = {‘background’: <MagicMock name=’mock.win32defines.MCSC_BACKGROUND’ id=‘1401987


set_border(border)
Set the calendar border
set_color(place_of_color, red, green, blue)
Set some color in some place of calendar which you specify.
Receive four parameters: - The first parameter may take few variants below: ‘background’,
‘month_background’, ‘text’, ‘title_background’, ‘title_text’, ‘trailing_text’ ; - All other parameters should
be integer from 0 to 255.
set_current_date(year, month, day_of_week, day)
Set the currently selected date
set_day_states(month_states)
Sets the day states for all months that are currently visible
set_first_weekday(dayNum)
Set first day of the week
set_id(ID)
Set the calendar type.
Receive only one parameter, which takes variants below: ‘gregorian’, ‘gregorian_us’, ‘japan’, ‘taiwan’,
‘korea’, ‘hijri’, ‘thai’, ‘hebrew’, ‘gregorian_me_french’, ‘gregorian_arabic’, ‘gregorian_english_xlit’,
‘gregorian_french_xlit’, ‘umalqura’
set_month_delta(delta)
Sets the scroll rate for a month calendar control.
set_today(year, month, day)
Set today date
set_view(viewType)
Set the calendar view
windowclasses = [’SysMonthCal32’]
class pywinauto.controls.common_controls.ComboBoxExWrapper(element_info)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows ComboBoxEx common control
friendlyclassname = ‘ComboBoxEx’
has_title = False
windowclasses = [’ComboBoxEx32’]
class pywinauto.controls.common_controls.DateTimePickerWrapper(element_info)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows DateTimePicker common control
GetTime(*args, **kwargs)
SetTime(*args, **kwargs)
friendlyclassname = ‘DateTimePicker’
get_time()
Get the currently selected time
has_title = False

11.4. Controls Reference 93


pywinauto Documentation, Release 0.6.8

set_time(year=0, month=0, day_of_week=0, day=0, hour=0, minute=0, second=0, milliseconds=0)


Set the currently selected time
windowclasses = [’SysDateTimePick32’, ‘WindowsForms\\d*\\.SysDateTimePick32\\..*’]
class pywinauto.controls.common_controls.HeaderWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows ListView Header common control
GetColumnRectangle(*args, **kwargs)
GetColumnText(*args, **kwargs)
ItemCount(*args, **kwargs)
client_rects()
Return all the client rectangles for the header control
friendlyclassname = ‘Header’
get_column_rectangle(column_index)
Return the rectangle for the column specified by column_index
get_column_text(column_index)
Return the text for the column specified by column_index
item_count()
Return the number of columns in this header
texts()
Return the texts of the Header control
windowclasses = [’SysHeader32’, ‘msvb_lib_header’]
class pywinauto.controls.common_controls.HotkeyWrapper(element_info)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows Hotkey common control
friendlyclassname = ‘Hotkey’
has_title = False
windowclasses = [’msctls_hotkey32’]
class pywinauto.controls.common_controls.IPAddressWrapper(element_info)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows IPAddress common control
friendlyclassname = ‘IPAddress’
has_title = False
windowclasses = [’SysIPAddress32’]
class pywinauto.controls.common_controls.ListViewWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows ListView common control
This class derives from HwndWrapper - so has all the methods o that class also
see hwndwrapper.HwndWrapper
Check(*args, **kwargs)

94 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

ColumnCount(*args, **kwargs)
ColumnWidths(*args, **kwargs)
Columns(*args, **kwargs)
Deselect(*args, **kwargs)
GetColumn(*args, **kwargs)
GetHeaderControl(*args, **kwargs)
GetItem(*args, **kwargs)
GetItemRect(*args, **kwargs)
GetSelectedCount(*args, **kwargs)
IsFocused(*args, **kwargs)
IsSelected(*args, **kwargs)
Item(*args, **kwargs)
ItemCount(*args, **kwargs)
Items(*args, **kwargs)
Select(*args, **kwargs)
UnCheck(*args, **kwargs)
check(item)
Check the ListView item
column_count()
Return the number of columns
column_widths()
Return a list of all the column widths
columns()
Get the information on the columns of the ListView
deselect(item)
Mark the item as not selected
The ListView control must be enabled and visible before an Item can be selected otherwise an exception
is raised
friendlyclassname = ‘ListView’
get_column(col_index)
Get the information for a column of the ListView
get_header_control()
Returns the Header control associated with the ListView
get_item(item_index, subitem_index=0)
Return the item of the list view”
•item_index Can be either an index of the item or a string with the text of the item you want returned.
•subitem_index A zero based index of the item you want returned. Defaults to 0.
get_item_rect(item_index)
Return the bounding rectangle of the list view item

11.4. Controls Reference 95


pywinauto Documentation, Release 0.6.8

get_selected_count()
Return the number of selected items
is_checked(item)
Return whether the ListView item is checked or not
is_focused(item)
Return True if the item has the focus
is_selected(item)
Return True if the item is selected
item(item_index, subitem_index=0)
Return the item of the list view”
•item_index Can be either an index of the item or a string with the text of the item you want returned.
•subitem_index A zero based index of the item you want returned. Defaults to 0.
item_count()
The number of items in the ListView
items()
Get all the items in the list view
select(item)
Mark the item as selected
The ListView control must be enabled and visible before an Item can be selected otherwise an exception
is raised
texts()
Get the texts for the ListView control
uncheck(item)
Uncheck the ListView item
windowclasses = [’SysListView32’, ‘WindowsForms\\d*\\.SysListView32\\..*’, ‘TSysListView’, ‘ListView.*WndClass’]
writable_props
Extend default properties list.
class pywinauto.controls.common_controls.PagerWrapper(element_info)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows Pager common control
GetPosition(*args, **kwargs)
SetPosition(*args, **kwargs)
friendlyclassname = ‘Pager’
get_position()
Return the current position of the pager
set_position(pos)
Set the current position of the pager
windowclasses = [’SysPager’]
class pywinauto.controls.common_controls.ProgressWrapper(element_info)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows Progress common control

96 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

GetPosition(*args, **kwargs)
GetState(*args, **kwargs)
GetStep(*args, **kwargs)
SetPosition(*args, **kwargs)
StepIt(*args, **kwargs)
friendlyclassname = ‘Progress’
get_position()
Return the current position of the progress bar
get_state()
Get the state of the progress bar
State will be one of the following constants:
• PBST_NORMAL
• PBST_ERROR
• PBST_PAUSED
get_step()
Get the step size of the progress bar
has_title = False
set_position(pos)
Set the current position of the progress bar
step_it()
Move the progress bar one step size forward
windowclasses = [’msctls_progress’, ‘msctls_progress32’]
class pywinauto.controls.common_controls.ReBarWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows ReBar common control
BandCount(*args, **kwargs)
GetBand(*args, **kwargs)
GetToolTipsControl(*args, **kwargs)
band_count()
Return the number of bands in the control
friendlyclassname = ‘ReBar’
get_band(band_index)
Get a band of the ReBar control
get_tool_tips_control()
Return the tooltip control associated with this control
texts()
Return the texts of the Rebar
windowclasses = [’ReBarWindow32’]
writable_props
Extend default properties list.

11.4. Controls Reference 97


pywinauto Documentation, Release 0.6.8

class pywinauto.controls.common_controls.StatusBarWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows Status Bar common control
BorderWidths(*args, **kwargs)
GetPartRect(*args, **kwargs)
GetPartText(*args, **kwargs)
PartCount(*args, **kwargs)
PartRightEdges(*args, **kwargs)
border_widths()
Return the border widths of the StatusBar
A dictionary of the 3 available widths is returned: Horizontal - the horizontal width Vertical - The width
above and below the status bar parts Inter - The width between parts of the status bar
client_rects()
Return the client rectangles for the control
friendlyclassname = ‘StatusBar’
get_part_rect(part_index)
Return the rectangle of the part specified by part_index
get_part_text(part_index)
Return the text of the part specified by part_index
part_count()
Return the number of parts
part_right_edges()
Return the widths of the parts
texts()
Return the texts for the control
windowclasses = [’msctls_statusbar32’, ‘.*StatusBar’, ‘WindowsForms\\d*\\.msctls_statusbar32\\..*’]
writable_props
Extend default properties list.
class pywinauto.controls.common_controls.TabControlWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows Tab common control
GetSelectedTab(*args, **kwargs)
GetTabRect(*args, **kwargs)
GetTabText(*args, **kwargs)
RowCount(*args, **kwargs)
Select(*args, **kwargs)
TabCount(*args, **kwargs)
client_rects()
Return the client rectangles for the Tab Control
friendlyclassname = ‘TabControl’

98 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

get_properties()
Return the properties of the TabControl as a Dictionary
get_selected_tab()
Return the index of the selected tab
get_tab_rect(tab_index)
Return the rectangle to the tab specified by tab_index
get_tab_text(tab_index)
Return the text of the tab
row_count()
Return the number of rows of tabs
select(tab)
Select the specified tab on the tab control
tab_count()
Return the number of tabs
texts()
Return the texts of the Tab Control
windowclasses = [’SysTabControl32’, ‘WindowsForms\\d*\\.SysTabControl32\\..*’]
writable_props
Extend default properties list.
class pywinauto.controls.common_controls.ToolTip(ctrl, tip_index)
Bases: object
Class that Wraps a single tip from a ToolTip control
class pywinauto.controls.common_controls.ToolTipsWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows ToolTips common control (not fully implemented)
GetTip(*args, **kwargs)
GetTipText(*args, **kwargs)
ToolCount(*args, **kwargs)
friendlyclassname = ‘ToolTips’
get_tip(tip_index)
Return the particular tooltip
get_tip_text(tip_index)
Return the text of the tooltip
texts()
Return the text of all the tooltips
tool_count()
Return the number of tooltips
windowclasses = [’tooltips_class32’, ‘.*ToolTip’, ‘#32774’, ‘MS_WINNOTE’, ‘VBBubble’]
class pywinauto.controls.common_controls.ToolbarWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows Toolbar common control

11.4. Controls Reference 99


pywinauto Documentation, Release 0.6.8

Button(*args, **kwargs)
ButtonCount(*args, **kwargs)
CheckButton(*args, **kwargs)
GetButton(*args, **kwargs)
GetButtonRect(*args, **kwargs)
GetButtonStruct(*args, **kwargs)
GetToolTipsControl(*args, **kwargs)
MenuBarClickInput(*args, **kwargs)
PressButton(*args, **kwargs)
TipTexts(*args, **kwargs)
button(button_identifier, exact=True, by_tooltip=False)
Return the button at index button_index
button_count()
Return the number of buttons on the ToolBar
check_button(button_identifier, make_checked, exact=True)
Find where the button is and click it if it’s unchecked and vice versa
friendlyclassname = ‘Toolbar’
get_button(button_index)
Return information on the Toolbar button
get_button_rect(button_index)
Get the rectangle of a button on the toolbar
get_button_struct(button_index)
Return TBBUTTON structure on the Toolbar button
get_tool_tips_control()
Return the tooltip control associated with this control
menu_bar_click_input(path, app)
Select menu bar items by path (experimental!)
The path is specified by a list of items separated by ‘->’ each Item can be the zero based index of the item
to return prefaced by # e.g. #1.
Example: “#1 -> #0”, “#1->#0->#0”
press_button(button_identifier, exact=True)
Find where the button is and click it
texts()
Return the texts of the Toolbar
tip_texts()
Return the tip texts of the Toolbar (without window text)
windowclasses = [’ToolbarWindow32’, ‘TToolBar’, ‘WindowsForms\\d*\\.ToolbarWindow32\\..*’, ‘Afx:ToolBar:.*’]
writable_props
Extend default properties list.

100 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

class pywinauto.controls.common_controls.TrackbarWrapper(element_info)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows Trackbar common control
friendlyclassname = ‘Trackbar’
get_channel_rect()
Get position of the bounding rectangle for a Trackbar
get_line_size()
Get the number of logical positions the trackbar’s slider
get_num_ticks()
Get trackbar num ticks
get_page_size()
Get the number of logical positions for the trackbar’s slider
get_position()
Get trackbar position
get_range_max()
Get max available trackbar value
get_range_min()
Get min available trackbar value
get_sel_end()
Get end of selection
get_sel_start()
Get start of selection
get_tooltips_control()
Get trackbar tooltip
set_line_size(line_size)
Set trackbar line size
set_page_size(page_size)
Set trackbar page size
set_position(pos)
Set trackbar position
set_range_max(range_max)
Set max available trackbar value
set_range_min(range_min)
Set min available trackbar value
set_sel(sel_start, sel_end)
Set start and end of selection
windowclasses = [’msctls_trackbar’]
class pywinauto.controls.common_controls.TreeViewWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows TreeView common control
EnsureVisible(*args, **kwargs)
GetItem(*args, **kwargs)

11.4. Controls Reference 101


pywinauto Documentation, Release 0.6.8

IsSelected(*args, **kwargs)
Item(*args, **kwargs)
ItemCount(*args, **kwargs)
PrintItems(*args, **kwargs)
Root(*args, **kwargs)
Roots(*args, **kwargs)
Select(*args, **kwargs)
ensure_visible(path)
Make sure that the TreeView item is visible
friendlyclassname = ‘TreeView’
get_item(path, exact=False)
Read the TreeView item
•path the path to the item to return. This can be one of the following:
–A string separated by \ characters. The first character must be \. This string is split on the \
characters and each of these is used to find the specific child at each level. The \ represents the
root item - so you don’t need to specify the root itself.
–A list/tuple of strings - The first item should be the root element.
–A list/tuple of integers - The first item the index which root to select.
get_properties()
Get the properties for the control as a dictionary
is_selected(path)
Return True if the item is selected
item(path, exact=False)
Read the TreeView item
•path the path to the item to return. This can be one of the following:
–A string separated by \ characters. The first character must be \. This string is split on the \
characters and each of these is used to find the specific child at each level. The \ represents the
root item - so you don’t need to specify the root itself.
–A list/tuple of strings - The first item should be the root element.
–A list/tuple of integers - The first item the index which root to select.
item_count()
Return the count of the items in the treeview
print_items()
Print all items with line indents
roots()
Get root items of the control
select(path)
Select the treeview item
texts()
Return all the text for the tree view

102 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

tree_root()
Return the root element of the tree view
windowclasses = [’SysTreeView32’, ‘WindowsForms\\d*\\.SysTreeView32\\..*’, ‘TTreeView’, ‘TreeList.TreeListCtrl’]
writable_props
Extend default properties list.
class pywinauto.controls.common_controls.UpDownWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Class that wraps Windows UpDown common control
Decrement(*args, **kwargs)
GetBase(*args, **kwargs)
GetBuddyControl(*args, **kwargs)
GetRange(*args, **kwargs)
GetValue(*args, **kwargs)
Increment(*args, **kwargs)
SetBase(*args, **kwargs)
SetValue(*args, **kwargs)
decrement()
Decrement the number in the UpDown control by one
friendlyclassname = ‘UpDown’
get_base()
Get the base the UpDown control (either 10 or 16)
get_buddy_control()
Get the buddy control of the updown control
get_range()
Return the lower, upper range of the up down control
get_value()
Get the current value of the UpDown control
increment()
Increment the number in the UpDown control by one
set_base(base_value)
Get the base the UpDown control (either 10 or 16)
set_value(new_pos)
Set the value of the of the UpDown control to some integer value
windowclasses = [’msctls_updown32’, ‘msctls_updown’]

11.4.5 pywinauto.controls.win32_controls

Wraps various standard windows controls


class pywinauto.controls.win32_controls.ButtonWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Wrap a windows Button control

11.4. Controls Reference 103


pywinauto Documentation, Release 0.6.8

Check(*args, **kwargs)
CheckByClick(*args, **kwargs)
CheckByClickInput(*args, **kwargs)
GetCheckState(*args, **kwargs)
SetCheckIndeterminate(*args, **kwargs)
UnCheck(*args, **kwargs)
UncheckByClick(*args, **kwargs)
UncheckByClickInput(*args, **kwargs)
can_be_label = True
check()
Check a checkbox
check_by_click()
Check the CheckBox control by click() method
check_by_click_input()
Check the CheckBox control by click_input() method
click(button=’left’, pressed=’‘, coords=(0, 0), double=False, absolute=False)
Click the Button control
friendly_class_name()
Return the friendly class name of the button
Windows controls with the class “Button” can look like different controls based on their style.
They can look like the following controls:
•Buttons, this method returns “Button”
•CheckBoxes, this method returns “CheckBox”
•RadioButtons, this method returns “RadioButton”
•GroupBoxes, this method returns “GroupBox”
friendlyclassname = ‘Button’
get_check_state()
Return the check state of the checkbox
The check state is represented by an integer 0 - unchecked 1 - checked 2 - indeterminate
The following constants are defined in the win32defines module BST_UNCHECKED = 0
BST_CHECKED = 1 BST_INDETERMINATE = 2
is_checked()
Return True if checked, False if not checked, None if indeterminate
is_dialog()
Buttons are never dialogs so return False
set_check_indeterminate()
Set the checkbox to indeterminate
uncheck()
Uncheck a checkbox
uncheck_by_click()
Uncheck the CheckBox control by click() method

104 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

uncheck_by_click_input()
Uncheck the CheckBox control by click_input() method
windowclasses = [’Button’, ‘.*Button’, ‘WindowsForms\\d*\\.BUTTON\\..*’, ‘.*CheckBox’]
class pywinauto.controls.win32_controls.ComboBoxWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Wrap a windows ComboBox control
DroppedRect(*args, **kwargs)
ItemCount(*args, **kwargs)
ItemData(*args, **kwargs)
ItemTexts(*args, **kwargs)
Select(*args, **kwargs)
SelectedIndex(*args, **kwargs)
SelectedText(*args, **kwargs)
dropped_rect()
Get the dropped rectangle of the combobox
friendlyclassname = ‘ComboBox’
get_properties()
Return the properties of the control as a dictionary
has_title = False
item_count()
Return the number of items in the combobox
item_data(item)
Returns the item data associated with the item if any
item_texts()
Return the text of the items of the combobox
select(item)
Select the ComboBox item
item can be either a 0 based index of the item to select or it can be the string that you want to
select
selected_index()
Return the selected index
selected_text()
Return the selected text
texts()
Return the text of the items in the combobox
windowclasses = [’ComboBox’, ‘WindowsForms\\d*\\.COMBOBOX\\..*’, ‘.*ComboBox’]
writable_props
Extend default properties list.
class pywinauto.controls.win32_controls.EditWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Wrap a windows Edit control

11.4. Controls Reference 105


pywinauto Documentation, Release 0.6.8

GetLine(*args, **kwargs)
LineCount(*args, **kwargs)
LineLength(*args, **kwargs)
Select(*args, **kwargs)
SelectionIndices(*args, **kwargs)
SetEditText(*args, **kwargs)
SetText(*args, **kwargs)
TextBlock(*args, **kwargs)
friendlyclassname = ‘Edit’
get_line(line_index)
Return the line specified
has_title = False
line_count()
Return how many lines there are in the Edit
line_length(line_index)
Return how many characters there are in the line
select(start=0, end=None)
Set the edit selection of the edit control
selection_indices()
The start and end indices of the current selection
set_edit_text(text, pos_start=None, pos_end=None)
Set the text of the edit control
set_text(text, pos_start=None, pos_end=None)
Set the text of the edit control
set_window_text(text, append=False)
Override set_window_text for edit controls because it should not be used for Edit controls.
Edit Controls should either use set_edit_text() or type_keys() to modify the contents of the edit
control.
text_block()
Get the text of the edit control
texts()
Get the text of the edit control
windowclasses = [’Edit’, ‘.*Edit’, ‘TMemo’, ‘WindowsForms\\d*\\.EDIT\\..*’, ‘ThunderTextBox’, ‘ThunderRT6T
writable_props
Extend default properties list.
class pywinauto.controls.win32_controls.ListBoxWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Wrap a windows ListBox control
GetItemFocus(*args, **kwargs)
IsSingleSelection(*args, **kwargs)

106 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

ItemCount(*args, **kwargs)
ItemData(*args, **kwargs)
ItemRect(*args, **kwargs)
ItemTexts(*args, **kwargs)
Select(*args, **kwargs)
SelectedIndices(*args, **kwargs)
SetItemFocus(*args, **kwargs)
friendlyclassname = ‘ListBox’
get_item_focus()
Retrun the index of current selection in a ListBox
has_title = False
is_single_selection()
Check whether the listbox has single selection mode.
item_count()
Return the number of items in the ListBox
item_data(i)
Return the item_data if any associted with the item
item_rect(item)
Return the rect of the item
item_texts()
Return the text of the items of the listbox
select(item, select=True)
Select the ListBox item
item can be either a 0 based index of the item to select or it can be the string that you want to
select
selected_indices()
The currently selected indices of the listbox
set_item_focus(item)
Set the ListBox focus to the item at index
texts()
Return the texts of the control
windowclasses = [’ListBox’, ‘WindowsForms\\d*\\.LISTBOX\\..*’, ‘.*ListBox’]
writable_props
Extend default properties list.
class pywinauto.controls.win32_controls.PopupMenuWrapper(element_info)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Wrap a Popup Menu
friendlyclassname = ‘PopupMenu’
has_title = False
is_dialog()
Return whether it is a dialog

11.4. Controls Reference 107


pywinauto Documentation, Release 0.6.8

windowclasses = [’#32768’]
class pywinauto.controls.win32_controls.StaticWrapper(hwnd)
Bases: pywinauto.controls.hwndwrapper.HwndWrapper
Wrap a windows Static control
can_be_label = True
friendlyclassname = ‘Static’
windowclasses = [’Static’, ‘WindowsForms\\d*\\.STATIC\\..*’, ‘TPanel’, ‘.*StaticText’]

11.4.6 pywinauto.controls.uiawrapper

Basic wrapping of UI Automation elements


class pywinauto.controls.uiawrapper.LazyProperty(fget)
Bases: object
A lazy evaluation of an object attribute.
The property should represent immutable data, as it replaces itself. Provided by: http://
stackoverflow.com/a/6849299/1260742
class pywinauto.controls.uiawrapper.UIAWrapper(element_info)
Bases: pywinauto.base_wrapper.BaseWrapper
Default wrapper for User Interface Automation (UIA) controls.
All other UIA wrappers are derived from this.
This class wraps a lot of functionality of underlying UIA features for working with windows.
Most of the methods apply to every single element type. For example you can click() on any element.

automation_id()
Return the Automation ID of the control
can_select_multiple()
An interface to CanSelectMultiple of the SelectionProvider pattern
Indicates whether the UI Automation provider allows more than one child element to be selected
concurrently.
children_texts()
Get texts of the control’s children
close()
Close the window
Only a control supporting Window pattern should answer. If it doesn’t (menu shadows,
tooltips,...), try to send “Esc” key
collapse()
Displays all child nodes, controls, or content of the control
An interface to Collapse method of the ExpandCollapse control pattern.
expand()
Displays all child nodes, controls, or content of the control
An interface to Expand method of the ExpandCollapse control pattern.

108 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

friendly_class_name()
Return the friendly class name for the control
This differs from the class of the control in some cases. class_name() is the actual ‘Registered’
window class of the control while friendly_class_name() is hopefully something that will make
more sense to the user.
For example Checkboxes are implemented as Buttons - so the class of a CheckBox is “Button”
- but the friendly class is “CheckBox”
get_expand_state()
Indicates the state of the control: expanded or collapsed.
An interface to CurrentExpandCollapseState property of the ExpandCollapse control pattern.
Values for enumeration as defined in uia_defines module: expand_state_collapsed = 0 ex-
pand_state_expanded = 1 expand_state_partially = 2 expand_state_leaf_node = 3
get_selection()
An interface to GetSelection of the SelectionProvider pattern
Retrieves a UI Automation provider for each child element that is selected. Builds a list of
UIAElementInfo elements from all retrieved providers.
get_show_state()
Get the show state and Maximized/minimzed/restored state
Returns values as following
window_visual_state_normal = 0 window_visual_state_maximized = 1 win-
dow_visual_state_minimized = 2
has_keyboard_focus()
Return True if the element is focused with keyboard
iface_expand_collapse = None
iface_grid = None
iface_grid_item = None
iface_invoke = None
iface_item_container = None
iface_range_value = None
iface_scroll = None
iface_scroll_item = None
iface_selection = None
iface_selection_item = None
iface_table = None
iface_table_item = None
iface_text = None
iface_toggle = None
iface_transform = None
iface_transformV2 = None
iface_value = None

11.4. Controls Reference 109


pywinauto Documentation, Release 0.6.8

iface_virtualized_item = None
iface_window = None
invoke()
An interface to the Invoke method of the Invoke control pattern
is_active()
Whether the window is active or not
is_collapsed()
Test if the control is collapsed
is_dialog()
Return true if the control is a dialog window (WindowPattern interface is available)
is_expanded()
Test if the control is expanded
is_keyboard_focusable()
Return True if the element can be focused with keyboard
is_maximized()
Indicate whether the window is maximized or not
is_minimized()
Indicate whether the window is minimized or not
is_normal()
Indicate whether the window is normal (i.e. not minimized and not maximized)
is_selected()
Indicate that the item is selected or not.
Only items supporting SelectionItem pattern should answer. Raise NoPatternInterfaceError if
the pattern is not supported
Usually applied for controls like: a radio button, a tree view item, a list item.
is_selection_required()
An interface to IsSelectionRequired property of the SelectionProvider pattern.
This property can be dynamic. For example, the initial state of a control might not have any
items selected by default, meaning that IsSelectionRequired is FALSE. However, after an item
is selected the control must always have at least one item selected.
legacy_properties()
Get the element’s LegacyIAccessible control pattern interface properties
maximize()
Maximize the window
Only controls supporting Window pattern should answer
menu_select(path, exact=False)
Select a menu item specified in the path
The full path syntax is specified in: pywinauto.menuwrapper.Menu.get_menu_path()
There are usually at least two menu bars: “System” and “Application” System menu bar is a
standard window menu with items like: ‘Restore’, ‘Move’, ‘Size’, ‘Minimize’, e.t.c. This menu
bar usually has a “Title Bar” control as a parent. Application menu bar is often what we look
for. In most cases, its parent is the dialog itself so it should be found among the direct children
of the dialog. Notice that we don’t use “Application” string as a title criteria because it couldn’t

110 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

work on applications with a non-english localization. If there is no menu bar has been found
we fall back to look up for Menu control. We try to find the control through all descendants of
the dialog
minimize()
Minimize the window
Only controls supporting Window pattern should answer
restore()
Restore the window to normal size
Only controls supporting Window pattern should answer
scroll(direction, amount, count=1, retry_interval=0.1)
Ask the control to scroll itself
direction can be any of “up”, “down”, “left”, “right” amount can be only “line” or “page”
count (optional) the number of times to scroll retry_interval (optional) interval between scroll
actions
select()
Select the item
Only items supporting SelectionItem pattern should answer. Raise NoPatternInterfaceError if
the pattern is not supported
Usually applied for controls like: a radio button, a tree view item or a list item.
selected_item_index()
Return the index of a selected item
set_focus()
Set the focus to this element
writable_props
Extend default properties list.
class pywinauto.controls.uiawrapper.UiaMeta(name, bases, attrs)
Bases: pywinauto.base_wrapper.BaseMeta
Metaclass for UiaWrapper objects
static find_wrapper(element)
Find the correct wrapper for this UIA element
pywinauto.controls.uiawrapper.lazy_property
alias of LazyProperty

11.4.7 pywinauto.controls.uia_controls

Wrap various UIA windows controls


class pywinauto.controls.uia_controls.ButtonWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap a UIA-compatible Button, CheckBox or RadioButton control
click()
Click the Button control by using Invoke or Select patterns

11.4. Controls Reference 111


pywinauto Documentation, Release 0.6.8

get_toggle_state()
Get a toggle state of a check box control.
The toggle state is represented by an integer 0 - unchecked 1 - checked 2 - indeterminate
The following constants are defined in the uia_defines module toggle_state_off = 0 tog-
gle_state_on = 1 toggle_state_inderteminate = 2
is_dialog()
Buttons are never dialogs so return False
toggle()
An interface to Toggle method of the Toggle control pattern.
Control supporting the Toggle pattern cycles through its toggle states in the following order:
ToggleState_On, ToggleState_Off and, if supported, ToggleState_Indeterminate
Usually applied for the check box control.
The radio button control does not implement IToggleProvider, because it is not capable of cy-
cling through its valid states. Toggle a state of a check box control. (Use ‘select’ method in-
stead) Notice, a radio button control isn’t supported by UIA. https://msdn.microsoft.com/en-us/
library/windows/desktop/ee671290(v=vs.85).aspx
class pywinauto.controls.uia_controls.ComboBoxWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap a UIA CoboBox control
collapse()
expand()
get_expand_state()
is_editable()
item_count()
Return the number of items in the combobox
The interface is kept mostly for a backward compatibility with the native ComboBox interface
select(item)
Select the ComboBox item
The item can be either a 0 based index of the item to select or it can be the string that you want
to select
selected_index()
Return the selected index
selected_text()
Return the selected text or None
Notice, that in case of multi-select it will be only the text from a first selected item
texts()
Return the text of the items in the combobox
class pywinauto.controls.uia_controls.EditWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap an UIA-compatible Edit control
get_line(line_index)
Return the line specified

112 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

get_value()
Return the current value of the element
has_title = False
is_editable()
Return the edit possibility of the element
line_count()
Return how many lines there are in the Edit
line_length(line_index)
Return how many characters there are in the line
select(start=0, end=None)
Set the edit selection of the edit control
selection_indices()
The start and end indices of the current selection
set_edit_text(text, pos_start=None, pos_end=None)
Set the text of the edit control
set_text(text, pos_start=None, pos_end=None)
Set the text of the edit control
set_window_text(text, append=False)
Override set_window_text for edit controls because it should not be used for Edit controls.
Edit Controls should either use set_edit_text() or type_keys() to modify the contents of the edit
control.
text_block()
Get the text of the edit control
texts()
Get the text of the edit control
writable_props
Extend default properties list.
class pywinauto.controls.uia_controls.HeaderItemWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap an UIA-compatible Header Item control
class pywinauto.controls.uia_controls.HeaderWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap an UIA-compatible Header control
class pywinauto.controls.uia_controls.ListItemWrapper(elem, con-
tainer=None)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap an UIA-compatible ListViewItem control
is_checked()
Return True if the ListItem is checked
Only items supporting Toggle pattern should answer. Raise NoPatternInterfaceError if the pat-
tern is not supported
texts()
Return a list of item texts

11.4. Controls Reference 113


pywinauto Documentation, Release 0.6.8

class pywinauto.controls.uia_controls.ListViewWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap an UIA-compatible ListView control
cell(row, column)
Return a cell in the ListView control
Only for controls with Grid pattern support
•row is an index of a row in the list.
•column is an index of a column in the specified row.
The returned cell can be of different control types. Mostly: TextBlock, ImageControl, EditCon-
trol, DataItem or even another layer of data items (Group, DataGrid)
cells()
Return list of list of cells for any type of contol
column_count()
Return the number of columns
columns()
Get the information on the columns of the ListView
get_column(col_index)
Get the information for a column of the ListView
get_header_control()
Return Header control associated with the ListView
get_header_controls()
Return Header controls associated with the Table
get_item(row)
Return an item of the ListView control
•row can be either an index of the row or a string with the text of a cell in the row you want
returned.
get_item_rect(item_index)
Return the bounding rectangle of the list view item
The method is kept mostly for a backward compatibility with the native ListViewWrapper in-
terface
get_items()
Return all items of the ListView control
get_selected_count()
Return a number of selected items
The call can be quite expensieve as we retrieve all the selected items in order to count them
item(row)
Return an item of the ListView control
•row can be either an index of the row or a string with the text of a cell in the row you want
returned.
item_count()
A number of items in the ListView
items()
Return all items of the ListView control

114 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

texts()
Return a list of item texts
writable_props
Extend default properties list.
class pywinauto.controls.uia_controls.MenuItemWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap an UIA-compatible MenuItem control
items()
Find all items of the menu item
select()
Apply Select pattern
class pywinauto.controls.uia_controls.MenuWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap an UIA-compatible MenuBar or Menu control
item_by_index(idx)
Find a menu item specified by the index
item_by_path(path, exact=False)
Find a menu item specified by the path
The full path syntax is specified in: controls.menuwrapper.Menu.get_menu_path()
Note: $ - specifier is not supported
items()
Find all menu items
class pywinauto.controls.uia_controls.SliderWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap an UIA-compatible Slider control
has_title = False
large_change()
Get a large change of slider’s thumb
This change is achieved by pressing PgUp and PgDown keys when slider’s thumb has keyboard
focus.
max_value()
Get the maximum value of the Slider
min_value()
Get the minimum value of the Slider
set_value(value)
Set position of slider’s thumb
small_change()
Get a small change of slider’s thumb
This change is achieved by pressing left and right arrows when slider’s thumb has keyboard
focus.
value()
Get a current position of slider’s thumb

11.4. Controls Reference 115


pywinauto Documentation, Release 0.6.8

class pywinauto.controls.uia_controls.StaticWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap an UIA-compatible Text control
can_be_label = True
class pywinauto.controls.uia_controls.TabControlWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap an UIA-compatible Tab control
get_selected_tab()
Return an index of a selected tab
select(item)
Select a tab by index or by name
tab_count()
Return a number of tabs
texts()
Tabs texts
class pywinauto.controls.uia_controls.ToolbarWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap an UIA-compatible ToolBar control
The control’s children usually are: Buttons, SplitButton, MenuItems, ThumbControls, TextControls,
Separators, CheckBoxes. Notice that ToolTip controls are children of the top window and not of the
toolbar.
button(button_identifier, exact=True)
Return a button by the specified identifier
•button_identifier can be either an index of a button or a string with the text of the button.
•exact flag specifies if the exact match for the text look up has to be applied.
button_count()
Return a number of buttons on the ToolBar
buttons()
Return all available buttons
check_button(button_identifier, make_checked, exact=True)
Find where the button is and toggle it
•button_identifier can be either an index of the button or a string with the text on the button.
•make_checked specifies the required toggled state of the button. If the button is already in
the specified state the state isn’t changed.
•exact flag specifies if the exact match for the text look up has to be applied
texts()
Return texts of the Toolbar
writable_props
Extend default properties list.
class pywinauto.controls.uia_controls.TooltipWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap an UIA-compatible Tooltip control
class pywinauto.controls.uia_controls.TreeItemWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper

116 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

Wrap an UIA-compatible TreeItem control


In addition to the provided methods of the wrapper additional inherited methods can be especially
helpful: select(), extend(), collapse(), is_extended(), is_collapsed(), click_input(), rectangle() and
many others
ensure_visible()
Make sure that the TreeView item is visible
get_child(child_spec, exact=False)
Return the child item of this item
Accepts either a string or an index. If a string is passed then it returns the child item with the
best match for the string.
is_checked()
Return True if the TreeItem is checked
Only items supporting Toggle pattern should answer. Raise NoPatternInterfaceError if the pat-
tern is not supported
sub_elements()
Return a list of all visible sub-items of this control
class pywinauto.controls.uia_controls.TreeViewWrapper(elem)
Bases: pywinauto.controls.uiawrapper.UIAWrapper
Wrap an UIA-compatible Tree control
get_item(path, exact=False)
Read a TreeView item
•path a path to the item to return. This can be one of the following:
–A string separated by \ characters. The first character must be \. This string is split on
the \ characters and each of these is used to find the specific child at each level. The \
represents the root item - so you don’t need to specify the root itself.
–A list/tuple of strings - The first item should be the root element.
–A list/tuple of integers - The first item the index which root to select. Indexing always
starts from zero: get_item((0, 2, 3))
•exact a flag to request exact match of strings in the path or apply a fuzzy logic of best_match
thus allowing non-exact path specifiers
item_count()
Return a number of items in TreeView
print_items()
Print all items with line indents
roots()
Return root elements of TreeView
writable_props
Extend default properties list.

11.5 Pre-supplied Tests

11.5.1 pywinauto.tests.allcontrols

Get All Controls Test

11.5. Pre-supplied Tests 117


pywinauto Documentation, Release 0.6.8

What is checked This test does no actual testing it just returns each control.
How is it checked A loop over all the controls in the dialog is made and each control added to the list of
bugs
When is a bug reported For each control.
Bug Extra Information There is no extra information associated with this bug type
Is Reference dialog needed No,but if available the reference control will be returned with the localised
control.
False positive bug reports Not possible
Test Identifier The identifier for this test/bug is “AllControls”
pywinauto.tests.allcontrols.AllControlsTest(windows)
Returns just one bug for each control

11.5.2 pywinauto.tests.asianhotkey

Asian Hotkey Format Test


What is checked
This test checks whether the format for shortcuts/hotkeys follows the standards for localised Windows
applications. This format is {localised text}({uppercase hotkey}) so for example if the English control is
“&Help” the localised control for Asian languages should be “LocHelp(H)”
How is it checked
After checking whether this control displays hotkeys it examines the 1st string of the control to make
sure that the format is correct. If the reference control is available then it also makes sure that the hotkey
character is the same as the reference. Controls with a title of less than 4 characters are ignored. This has
been done to avoid false positive bug reports for strings like “&X:”.
When is a bug reported
A bug is reported when a control has a hotkey and it is not in the correct format. Also if the reference
control is available a bug will be reported if the hotkey character is not the same as used in the reference
Bug Extra Information
This test produces 2 different types of bug: BugType: “AsianHotkeyFormat” There is no extra information
associated with this bug type
BugType: “AsianHotkeyDiffRef”
There is no extra information associated with this bug type
Is Reference dialog needed
The reference dialog is not needed. If it is unavailable then only bugs of type “AsianHotkeyFormat” will
be reported, bug of type “AsianHotkeyDiffRef” will not be found.
False positive bug reports
There should be very few false positive bug reports when testing Asian software. If a string is very short
(eg “&Y:”) but is padded with spaces then it will get reported.
Test Identifier
The identifier for this test/bug is “AsianHotkeyTests”

118 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

pywinauto.tests.asianhotkey.AsianHotkeyTest(windows)
Return the repeated hotkey errors

11.5.3 pywinauto.tests.comboboxdroppedheight

ComboBox dropped height Test


What is checked It is ensured that the height of the list displayed when the combobox is dropped down
is not less than the height of the reference.
How is it checked The value for the dropped rectangle can be retrieved from windows. The height of this
rectangle is calculated and compared against the reference height.
When is a bug reported If the height of the dropped rectangle for the combobox being checked is less
than the height of the reference one then a bug is reported.
Bug Extra Information There is no extra information associated with this bug type
Is Reference dialog needed The reference dialog is necessary for this test.
False positive bug reports No false bugs should be reported. If the font of the localised control has a
smaller height than the reference then it is possible that the dropped rectangle could be of a different size.
Test Identifier The identifier for this test/bug is “ComboBoxDroppedHeight”
pywinauto.tests.comboboxdroppedheight.ComboBoxDroppedHeightTest(windows)
Check if each combobox height is the same as the reference

11.5.4 pywinauto.tests.comparetoreffont

Compare against reference font test


What is checked This test checks all the parameters of the font for the control against the font for the
reference control. If any value is different then this is reported as a bug. Here is a list of all the possible
values that are tested: lfFaceName The name of the font lfHeight The height of the font lfWidth Average
width of characters lfEscapement Angle of text lfOrientation Another angle for the text! lfWeight How
bold the text is lfItalic If the font is italic lfUnderline If the font is underlined lfStrikeOut If the font is
struck out lfCharSet The character set of the font lfOutPrecision The output precision lfClipPrecision The
clipping precision lfQuality The output quality lfPitchAndFamily The pitch and family
How is it checked Each property of the font for the control being tested is compared against the equivalent
property of the reference control font for equality.
When is a bug reported For each property of the font that is not identical to the reference font a bug is
reported. So for example if the Font Face has changed and the text is bold then (at least) 2 bugs will be
reported.
Bug Extra Information The bug contains the following extra information Name Description ValueType
What value is incorrect (see above), String Ref The reference value converted to a string, String Loc The
localised value converted to a string, String
Is Reference dialog needed This test will not run if the reference controls are not available.
False positive bug reports Running this test for Asian languages will result in LOTS and LOTS of false
positives, because the font HAS to change for the localised text to display properly.
Test Identifier The identifier for this test/bug is “CompareToRefFont”
pywinauto.tests.comparetoreffont.CompareToRefFontTest(windows)
Compare the font to the font of the reference control

11.5. Pre-supplied Tests 119


pywinauto Documentation, Release 0.6.8

11.5.5 pywinauto.tests.leadtrailspaces

Different Leading and Trailing Spaces Test


What is checked Checks that the same space characters (<space>, <tab>, <enter>, <vertical tab>) are
before and after all non space characters in the title of the control when compared to the reference control.
How is it checked Find the 1st non-space character, and the characters of the title up to that are the leading
spaces. Find the last non-space character, and the characters of the title after that are the trailing spaces.
These are then compared to the lead and trail spaces from the reference control and if they are not exactly
the then a bug is reported.
When is a bug reported When either the leading or trailing spaces of the control being tested does not
match the equivalent spaces of the reference control exactly.
Bug Extra Information The bug contains the following extra information
• Lead-Trail Whether this bug report is for the leading or trailing spaces of the control, String
This will be either:
– “Leading” bug relating to leading spaces
– “Trailing” bug relating to trailing spaces
• Ref The leading or trailings spaces of the reference string (depending on Lead-Trail value), String
• Loc The leading or trailings spaces of the local string (depending on Lead-Trail value), String
Is Reference dialog needed This test will not run if the reference controls are not available.
False positive bug reports This is usually not a very important test, so if it generates many false positives
then we should consider removing it.
Test Identifier The identifier for this test/bug is “LeadTrailSpaces”
pywinauto.tests.leadtrailspaces.GetLeadSpaces(title)
Return the leading spaces of the string
pywinauto.tests.leadtrailspaces.GetTrailSpaces(title)
Return the trailing spaces of the string
pywinauto.tests.leadtrailspaces.LeadTrailSpacesTest(windows)
Return the leading/trailing space bugs for the windows

11.5.6 pywinauto.tests.miscvalues

Miscellaneous Control properties Test


What is checked This checks various values related to a control in windows. The values tested are
class_name The class type of the control style The Style of the control (GetWindowLong) exstyle The
Extended Style of the control (GetWindowLong) help_id The Help ID of the control (GetWindowLong)
control_id The Control ID of the control (GetWindowLong) user_data The User Data of the control
(GetWindowLong) Visibility Whether the control is visible or not
How is it checked After retrieving the information for the control we compare it to the same information
from the reference control.
When is a bug reported If the information does not match then a bug is reported.
Bug Extra Information The bug contains the following extra information Name Description ValueType
What value is incorrect (see above), String Ref The reference value converted to a string, String Loc The
localised value converted to a string, String

120 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

Is Reference dialog needed This test will not run if the reference controls are not available.
False positive bug reports Some values can change easily without any bug being caused, for example
User Data is actually meant for programmers to store information for the control and this can change
every time the software is run.
Test Identifier The identifier for this test/bug is “MiscValues”
pywinauto.tests.miscvalues.MiscValuesTest(windows)
Return the bugs from checking miscelaneous values of a control

11.5.7 pywinauto.tests.missalignment

Missalignment Test
What is checked This test checks that if a set of controls were aligned on a particular axis in the reference
dialog that they are all aligned on the same axis.
How is it checked A list of all the reference controls that are aligned is created (ie more than one control
with the same Top, Left, Bottom or Right coordinates). These controls are then analysed in the localised
dialog to make sure that they are all aligned on the same axis.
When is a bug reported A bug is reported when any of the controls that were aligned in the reference
dialog are no longer aligned in the localised control.
Bug Extra Information The bug contains the following extra information Name Description Alignment-
Type This is either LEFT, TOP, RIGHT or BOTTOM. It tells you how the controls were aligned in the
reference dialog. String AlignmentRect Gives the smallest rectangle that surrounds ALL the controls
concerned in the bug, rectangle
Is Reference dialog needed This test cannot be performed without the reference control. It is required to
see which controls should be aligned.
False positive bug reports It is quite possible that this test reports false positives: 1. Where the controls
only just happen to be aligned in the reference dialog (by coincidence) 2. Where the control does not
have a clear boundary (for example static labels or checkboxes) they may be miss-aligned but it is not
noticeable that they are not.
Test Identifier The identifier for this test/bug is “Missalignment”
pywinauto.tests.missalignment.MissalignmentTest(windows)
Run the test on the windows passed in

11.5.8 pywinauto.tests.missingextrastring

Different number of special character sequences Test


What is checked This test checks to make sure that certain special character sequences appear the in the
localised if they appear in the reference title strings. These strings usually mean something to the user but
the software internally does not care if they exist or not. The list that is currently checked is: “>>”, “>”,
“<<”, “<”, ”:”(colon), ”...”, “&&”, “&”, “”
How is it checked For each of the string to check for we make sure that if it appears in the reference that
it also appears in the localised title.
When is a bug reported
• If the reference has one of the text strings but the localised does not a bug is reported.
• If the localised has one of the text strings but the reference does not a bug is reported.

11.5. Pre-supplied Tests 121


pywinauto Documentation, Release 0.6.8

Bug Extra Information The bug contains the following extra information
MissingOrExtra Whether the characters are missing or extra from the controls being check as compared
to the reference, (String with following possible values)
• “MissingCharacters” The characters are in the reference but not in the localised.
• “ExtraCharacters” The characters are not in the reference but are in the localised.
MissingOrExtraText What character string is missing or added, String
Is Reference dialog needed This test will not run if the reference controls are not available.
False positive bug reports Currently this test is at a beta stage filtering of the results is probably necessary
at the moment.
Test Identifier The identifier for this test/bug is “MissingExtraString”
pywinauto.tests.missingextrastring.MissingExtraStringTest(windows)
Return the errors from running the test

11.5.9 pywinauto.tests.overlapping

Overlapping Test
What is checked The overlapping test checks for controls that occupy the same space as some other
control in the dialog.
• If the reference controls are available check for each pair of controls:
– If controls are exactly the same size and position in reference then make sure that they are also
in the localised.
– If a reference control is wholly contained in another make sure that the same happens for the
controls being tested.
• If the reference controls are not available only the following check can be done
– If controls are overlapped in localised report a bug (if reference is available it is used just to say
if this overlapping happens in reference also)
How is it checked Various tests are performed on each pair of controls to see if any of the above conditions
are met. The most specific tests that can be performed are done 1st so that the bugs reported are as specific
as possible. I.e. we report that 2 controls are not exactly overlapped when they should be rather than jut
reporting that they are overlapped which contains less information.
When is a bug reported A bug is reported when:
• controls are overlapped (but not contained wholly, and not exactly overlapped)
• reference controls are exactly overlapped but they are not in tested dialog
• one reference control is wholly contained in another but not in tested dialog
Bug Extra Information This test produces 3 different types of bug: BugType: “Overlapping” Name
Description OverlappedRect <What this info is>, rectangle
BugType - “NotContainedOverlap” There is no extra information associated with this bug type
BugType - “NotExactOverlap” There is no extra information associated with this bug type
Is Reference dialog needed For checking whether controls should be exactly overlapped and whether
they should be wholly contained the reference controls are necessary. If the reference controls are not
available then only simple overlapping of controls will be checked.

122 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

False positive bug reports If there are controls in the dialog that are not visible or are moved dynamically
it may cause bugs to be reported that do not need to be logged. If necessary filter out bugs with hidden
controls.
Test Identifier The identifier for this test is “Overlapping”
class pywinauto.tests.overlapping.OptRect
pywinauto.tests.overlapping.OverlappingTest(windows)
Return the repeated hotkey errors

11.5.10 pywinauto.tests.repeatedhotkey

Repeated Hotkeys Test


What is checked This test checks all the controls in a dialog to see if there are controls that use the same
hotkey character.
How is it checked A list of all the hotkeys (converted to uppercase) used in the dialog is created. Then
this list is examined to see if any hotkeys are used more than once. If any are used more than once a list
of all the controls that use this hotkey are compiled to be used in the bug report.
When is a bug reported If more than one control has the same hotkey then a bug is reported.
Bug Extra Information The bug contains the following extra information Name Description Repeated-
Hotkey This is the hotkey that is repeated between the 2 controls converted to uppercase, String Char-
sUsedInDialog This is a list of all the hotkeys used in the dialog, String AllCharsInDialog This is a list of
all the characters in the dialog for controls that have a hotkeys, String AvailableInControlS A list of the
available characters for each control. Any of the characters in this list could be used as the new hotkey
without conflicting with any existing hotkey.
Is Reference dialog needed The reference dialog does not need to be available. If it is available then for
each bug discovered it is checked to see if it is a problem in the reference dialog. NOTE: Checking the
reference dialog is not so exact here! Only when the equivalent controls in the reference dialog all have
the hotkeys will it be reported as being in the reference also. I.e. if there are 3 controls with the same
hotkey in the Localised software then those same controls in the reference dialog must have the same
hotkey for it to be reported as existing in the reference also.
False positive bug reports There should be very few false positives from this test. Sometimes a control
only has one or 2 characters eg “X:” and it is impossible to avoid a hotkey clash. Also for Asian languages
hotkeys should be the same as the US software so probably this test should be run on those languages.
Test Identifier The identifier for this test/bug is “RepeatedHotkey”
pywinauto.tests.repeatedhotkey.GetHotkey(text)
Return the position and character of the hotkey
pywinauto.tests.repeatedhotkey.ImplementsHotkey(win)
checks whether a control interprets & character to be a hotkey
pywinauto.tests.repeatedhotkey.RepeatedHotkeyTest(windows)
Return the repeated hotkey errors

11.5.11 pywinauto.tests.translation

Translation Test
What is checked This checks for controls which appear not to be translated.
How is it checked It compares the text of the localised and reference controls.

11.5. Pre-supplied Tests 123


pywinauto Documentation, Release 0.6.8

If there are more than string in the control then each item is searched for in the US list of titles (so checking
is not order dependent). The indices for the untranslated strings are returned in a comma separated string.
Also the untranslated strings themselves are returned (all as one string). These strings are not escaped and
are delimited as “string1”,”string2”,...”stringN”.
When is a bug reported
If the text of the localised control is identical to the reference control (in case, spacing i.e. a
binary compare) then it will be flagged as untranslated. Otherwise the control is treated as
translated.
Note: This is the method to return the least number of bugs. If there are differences in any part of the string
(e.g. a path or variable name) but the rest of the string is untranslated then a bug will not be highlighted
Bug Extra Information The bug contains the following extra information Name Description Strings
The list of the untranslated strings as explained above StringIndices The list of indices (0 based) that are
untranslated. This will usually be 0 but if there are many strings in the control untranslated it will report
ALL the strings e.g. 0,2,5,19,23
Is Reference dialog needed The reference dialog is always necessary.
False positive bug reports False positive bugs will be reported in the following cases. - The title of the
control stays the same as the US because the translation is the same as the English text(e.g. Name: in
German) - The title of the control is not displayed (and not translated). This can sometimes happen if the
programmer displays something else on the control after the dialog is created.
Test Identifier The identifier for this test/bug is “Translation”
pywinauto.tests.translation.TranslationTest(windows)
Returns just one bug for each control

11.5.12 pywinauto.tests.truncation

Truncation Test
What is checked Checks for controls where the text does not fit in the space provided by the control.
How is it checked There is a function in windows (DrawText) that allows us to find the size that certain
text will need. We use this function with correct fonts and other relevant information for the control to be
as accurate as possible.
When is a bug reported When the calculated required size for the text is greater than the size of the space
available for displaying the text.
Bug Extra Information The bug contains the following extra information Name Description Strings
The list of the truncated strings as explained above StringIndices The list of indices (0 based) that are
truncated. This will often just be 0 but if there are many strings in the control untranslated it will report
ALL the strings e.g. 0,2,5,19,23
Is Reference dialog needed The reference dialog does not need to be available. If it is available then for
each bug discovered it is checked to see if it is a problem in the reference dialog.
False positive bug reports Certain controls do not display the text that is the title of the control, if this is
not handled in a standard manner by the software then DLGCheck will report that the string is truncated.
Test Identifier The identifier for this test/bug is “Truncation”
pywinauto.tests.truncation.TruncationTest(windows)
Actually do the test

124 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

11.6 Backend Internal Implementation modules

11.6.1 pywinauto.backend

Back-end components storage (links to platform-specific things)


class pywinauto.backend.BackEnd(name, element_info_class, generic_wrapper_class)
Minimal back-end description (name & 2 required base classes)
class pywinauto.backend.BackendsRegistry
Registry pattern class for the list of available back-ends
element_class
Return element_info.ElementInfo‘s subclass of the active backend
name
Name of the active backend
wrapper_class
BaseWrapper’s subclass of the active backend
pywinauto.backend.activate(name)
Set active backend by name
Possible values of name are “win32”, “uia” or other name registered by the register() function.
pywinauto.backend.element_class()
Return element_info.ElementInfo‘s subclass of the active backend
pywinauto.backend.name()
Return name of the active backend
pywinauto.backend.register(name, element_info_class, generic_wrapper_class)
Register a new backend
pywinauto.backend.wrapper_class()
Return BaseWrapper’s subclass of the active backend

11.6.2 pywinauto.element_info

Interface for classes which should deal with different backend elements
class pywinauto.element_info.ElementInfo
Abstract wrapper for an element
children(**kwargs)
Return children of the element
class_name
Return the class name of the element
control_id
Return the ID of the control
descendants(**kwargs)
Return descendants of the element
dump_window()
Dump an element to a set of properties

11.6. Backend Internal Implementation modules 125


pywinauto Documentation, Release 0.6.8

enabled
Return True if the element is enabled
static filter_with_depth(elements, root, depth)
Return filtered elements with particular depth level relative to the root
framework_id
Return the framework of the element
handle
Return the handle of the element
has_depth(root, depth)
Return True if element has particular depth level relative to the root
iter_children(**kwargs)
Iterate over children of element
iter_descendants(**kwargs)
Iterate over descendants of the element
name
Return the name of the element
parent
Return the parent of the element
process_id
Return the ID of process that controls this element
rectangle
Return rectangle of element
rich_text
Return the text of the element
set_cache_strategy(cached)
Set a cache strategy for frequently used attributes of the element
visible
Return True if the element is visible

11.6.3 pywinauto.win32_element_info

Implementation of the class to deal with a native element (window with a handle)
class pywinauto.win32_element_info.HwndElementInfo(handle=None)
Wrapper for window handler
automation_id
Return AutomationId of the element
children(**kwargs)
Return a list of immediate children of the window
class_name
Return the class name of the window
control_id
Return the ID of the window
control_type
Return control type of the element

126 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

descendants(**kwargs)
Return descendants of the window (all children from sub-tree)
dump_window()
Dump a window as a set of properties
enabled
Return True if the window is enabled
classmethod from_point(x, y)
full_control_type
Return full string of control type of the element
handle
Return the handle of the window
iter_children(**kwargs)
Return a generator of immediate children of the window
name
Return the text of the window
parent
Return the parent of the window
process_id
Return the ID of process that controls this window
rectangle
Return rectangle of the element
rich_text
Return the text of the window
set_cache_strategy(cached)
Set a cache strategy for frequently used attributes of the element
classmethod top_from_point(x, y)
visible
Return True if the window is visible
wm_get_ctrl_name = -1
wm_get_ctrl_type = -1

11.6.4 pywinauto.uia_element_info

Implementation of the class to deal with an UI element (based on UI Automation API)


class pywinauto.uia_element_info.UIAElementInfo(handle_or_elem=None,
cache_enable=False)
UI element wrapper for IUIAutomation API
automation_id
Return AutomationId of the element
children(**kwargs)
Return a list of only immediate children of the element
•kwargs is a criteria to reduce a list by process, class_name, control_type, content_only
and/or title.

11.6. Backend Internal Implementation modules 127


pywinauto Documentation, Release 0.6.8

class_name
Return class name of the element
control_id
Return ControlId of the element if it has a handle
control_type
Return control type of element
descendants(**kwargs)
Return a list of all descendant children of the element
•kwargs is a criteria to reduce a list by process, class_name, control_type, content_only
and/or title.
dump_window()
Dump window to a set of properties
element
Return AutomationElement’s instance
enabled
Check if the element is enabled
framework_id
Return FrameworkId of the element
classmethod from_point(x, y)
handle
Return handle of the element
iter_children(**kwargs)
Return a generator of only immediate children of the element
•kwargs is a criteria to reduce a list by process, class_name, control_type, content_only
and/or title.
name
Return name of the element
parent
Return parent of the element
process_id
Return ProcessId of the element
rectangle
Return rectangle of the element
rich_text
Return rich_text of the element
runtime_id
Return Runtime ID (hashable value but may be different from run to run)
set_cache_strategy(cached=None)
Setup a cache strategy for frequently used attributes
classmethod top_from_point(x, y)
visible
Check if the element is visible

128 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

pywinauto.uia_element_info.elements_from_uia_array(ptrs,
cache_enable=False)
Build a list of UIAElementInfo elements from IUIAutomationElementArray

11.6.5 pywinauto.uia_defines

Common UIA definitions and helper functions


class pywinauto.uia_defines.IUIA
Singleton class to store global COM objects from UIAutomationCore.dll
build_condition(process=None, class_name=None, title=None, control_type=None,
content_only=None)
Build UIA filtering conditions
exception pywinauto.uia_defines.NoPatternInterfaceError
There is no such interface for the specified pattern
pywinauto.uia_defines.get_elem_interface(element_info, pattern_name)
A helper to retrieve an element interface by the specified pattern name
TODO: handle a wrong pattern name

11.7 Internal Modules

11.7.1 pywinauto.controlproperties

Wrap
class pywinauto.controlproperties.ControlProps(*args, **kwargs)
Wrap controls read from a file to resemble hwnd controls
HasExStyle(*args, **kwargs)
HasStyle(*args, **kwargs)
WindowText(*args, **kwargs)
has_exstyle(exstyle)
has_style(style)
window_text()
class pywinauto.controlproperties.FuncWrapper(value)
Little class to allow attribute access to return a callable object
pywinauto.controlproperties.GetMenuBlocks(ctrls)
pywinauto.controlproperties.MenuBlockAsControls(menuItems, parent-
age=None)
pywinauto.controlproperties.MenuItemAsControl(menuItem)
Make a menu item look like a control for tests
pywinauto.controlproperties.SetReferenceControls(controls, refControls)
Set the reference controls for the controls passed in
This does some minor checking as following:

11.7. Internal Modules 129


pywinauto Documentation, Release 0.6.8

• test that there are the same number of reference controls as controls - fails with an exception
if there are not
• test if all the ID’s are the same or not

11.7.2 pywinauto.handleprops

Functions to retrieve properties from a window handle


These are implemented in a procedural way so as to to be useful to other modules with the least conceptual
overhead
pywinauto.handleprops.children(handle)
Return a list of handles to the children of this window
pywinauto.handleprops.classname(handle)
Return the class name of the window
pywinauto.handleprops.clientrect(handle)
Return the client rectangle of the control
pywinauto.handleprops.contexthelpid(handle)
Return the context help id of the window
pywinauto.handleprops.controlid(handle)
Return the ID of the control
pywinauto.handleprops.dumpwindow(handle)
Dump a window to a set of properties
pywinauto.handleprops.exstyle(handle)
Return the extended style of the window
pywinauto.handleprops.font(handle)
Return the font as a LOGFONTW of the window
pywinauto.handleprops.has_enough_privileges(process_id)
Check if target process has enough rights to query GUI actions
pywinauto.handleprops.has_exstyle(handle, tocheck)
Return True if the control has extended style tocheck
pywinauto.handleprops.has_style(handle, tocheck)
Return True if the control has style tocheck
pywinauto.handleprops.is64bitbinary(filename)
Check if the file is 64-bit binary
pywinauto.handleprops.is64bitprocess(process_id)
Return True if the specified process is a 64-bit process on x64
Return False if it is only a 32-bit process running under Wow64. Always return False for x86.
pywinauto.handleprops.is_toplevel_window(handle)
Return whether the window is a top level window or not
pywinauto.handleprops.isenabled(handle)
Return True if the window is enabled
pywinauto.handleprops.isunicode(handle)
Return True if the window is a Unicode window

130 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

pywinauto.handleprops.isvisible(handle)
Return True if the window is visible
pywinauto.handleprops.iswindow(handle)
Return True if the handle is a window
pywinauto.handleprops.parent(handle)
Return the handle of the parent of the window
pywinauto.handleprops.processid(handle)
Return the ID of process that controls this window
pywinauto.handleprops.rectangle(handle)
Return the rectangle of the window
pywinauto.handleprops.style(handle)
Return the style of the window
pywinauto.handleprops.text(handle)
Return the text of the window
pywinauto.handleprops.userdata(handle)
Return the value of any user data associated with the window

11.7.3 pywinauto.xml_helpers

Module containing operations for reading and writing dialogs as XML


pywinauto.xml_helpers.ReadPropertiesFromFile(filename)
Return a list of controls from XML file filename
pywinauto.xml_helpers.WriteDialogToFile(filename, props)
Write the props to the file
props can be either a dialog or a dictionary
exception pywinauto.xml_helpers.XMLParsingError
Wrap parsing Exceptions

11.7.4 pywinauto.fuzzydict

Match items in a dictionary using fuzzy matching


Implemented for pywinauto.
This class uses difflib to match strings. This class uses a linear search to find the items as it HAS to iterate
over every item in the dictionary (otherwise it would not be possible to know which is the ‘best’ match).
If the exact item is in the dictionary (no fuzzy matching needed - then it doesn’t do the linear search and
speed should be similar to standard Python dictionaries.
>>> fuzzywuzzy = FuzzyDict({"hello" : "World", "Hiya" : 2, "Here you are" : 3})
>>> fuzzywuzzy['Me again'] = [1,2,3]
>>>
>>> fuzzywuzzy['Hi']
2
>>>
>>>
>>> # next one doesn't match well enough - so a key error is raised
...

11.7. Internal Modules 131


pywinauto Documentation, Release 0.6.8

>>> fuzzywuzzy['There']
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "pywinauto
uzzydict.py", line 125, in __getitem__
raise KeyError(
KeyError: "'There'. closest match: 'hello' with ratio 0.400"
>>>
>>> fuzzywuzzy['you are']
3
>>> fuzzywuzzy['again']
[1, 2, 3]
>>>

class pywinauto.fuzzydict.FuzzyDict(items=None, cutoff=0.6)


Provides a dictionary that performs fuzzy lookup

11.7.5 pywinauto.actionlogger

pywinauto.actionlogger.ActionLogger
alias of _StandardLogger
pywinauto.actionlogger.disable()
Disable pywinauto logging actions
pywinauto.actionlogger.enable()
Enable pywinauto logging actions
pywinauto.actionlogger.reset_level()
Reset a logging level to a default
pywinauto.actionlogger.set_level(level)
Set a logging level for the pywinauto logger.

11.7.6 pywinauto.sysinfo

Simple module for checking whether Python and Windows are 32-bit or 64-bit
pywinauto.sysinfo.is_x64_OS()
pywinauto.sysinfo.is_x64_Python()
pywinauto.sysinfo.os_arch()
pywinauto.sysinfo.python_bitness()

11.7.7 pywinauto.remote_memory_block

Module containing wrapper around VirtualAllocEx/VirtualFreeEx Win32 API functions to perform cus-
tom marshalling
exception pywinauto.remote_memory_block.AccessDenied
Raised when we cannot allocate memory in the control’s process
class pywinauto.remote_memory_block.RemoteMemoryBlock(ctrl, size=4096)
Class that enables reading and writing memory in a different process

132 Chapter 11. Source code reference


pywinauto Documentation, Release 0.6.8

Address()
Return the address of the memory block
CheckGuardSignature()
read guard signature at the end of memory block
CleanUp()
Free Memory and the process handle
Read(data, address=None, size=None)
Read data from the memory block
Write(data, address=None, size=None)
Write data into the memory block

11.7. Internal Modules 133


pywinauto Documentation, Release 0.6.8

134 Chapter 11. Source code reference


CHAPTER 12

Indices and tables

• genindex
• modindex
• search

135
pywinauto Documentation, Release 0.6.8

136 Chapter 12. Indices and tables


Python Module Index

p pywinauto.xml_helpers, 131
pywinauto.actionlogger, 132
pywinauto.application, 65
pywinauto.backend, 125
pywinauto.base_wrapper, 76
pywinauto.clipboard, 75
pywinauto.controlproperties, 129
pywinauto.controls.common_controls, 89
pywinauto.controls.hwndwrapper, 80
pywinauto.controls.menuwrapper, 87
pywinauto.controls.uia_controls, 111
pywinauto.controls.uiawrapper, 108
pywinauto.controls.win32_controls, 103
pywinauto.element_info, 125
pywinauto.findbestmatch, 69
pywinauto.findwindows, 70
pywinauto.fuzzydict, 131
pywinauto.handleprops, 130
pywinauto.keyboard, 63
pywinauto.mouse, 63
pywinauto.remote_memory_block, 132
pywinauto.sysinfo, 132
pywinauto.tests.allcontrols, 117
pywinauto.tests.asianhotkey, 118
pywinauto.tests.comboboxdroppedheight,
119
pywinauto.tests.comparetoreffont, 119
pywinauto.tests.leadtrailspaces, 120
pywinauto.tests.miscvalues, 120
pywinauto.tests.missalignment, 121
pywinauto.tests.missingextrastring, 121
pywinauto.tests.overlapping, 122
pywinauto.tests.repeatedhotkey, 123
pywinauto.tests.translation, 123
pywinauto.tests.truncation, 124
pywinauto.timings, 72
pywinauto.uia_defines, 129
pywinauto.uia_element_info, 127
pywinauto.win32_element_info, 126
pywinauto.win32_hooks, 75

137
pywinauto Documentation, Release 0.6.8

138 Python Module Index


Index

Symbols automation_id (pywinauto.uia_element_info.UIAElementInfo


__getattribute__() (pywinauto.application.Application attribute), 127
method), 65 automation_id (pywinauto.win32_element_info.HwndElementInfo
__getattribute__() (pywin- attribute), 126
auto.application.WindowSpecification automation_id() (pywin-
method), 67 auto.controls.hwndwrapper.HwndWrapper
__getitem__() (pywinauto.application.Application method), 82
method), 65 automation_id() (pywin-
__getitem__() (pywinauto.application.WindowSpecification auto.controls.uiawrapper.UIAWrapper
method), 67 method), 108
_listview_item (class in pywin-
auto.controls.common_controls), 90
B
_toolbar_button (class in pywin- BackEnd (class in pywinauto.backend), 125
auto.controls.common_controls), 89 BackendsRegistry (class in pywinauto.backend), 125
_treeview_element (class in pywin- band_count() (pywinauto.controls.common_controls.ReBarWrapper
auto.controls.common_controls), 89 method), 97
BandCount() (pywinauto.controls.common_controls.ReBarWrapper
A method), 97
AccessDenied, 132 BaseMeta (class in pywinauto.base_wrapper), 76
ActionLogger (in module pywinauto.actionlogger), 132 BaseWrapper (class in pywinauto.base_wrapper), 76
activate() (in module pywinauto.backend), 125 border_widths() (pywin-
active() (pywinauto.application.Application method), 66 auto.controls.common_controls.StatusBarWrapper
Address() (pywinauto.remote_memory_block.RemoteMemoryBlock method), 98
method), 132 BorderWidths() (pywin-
AllControlsTest() (in module pywin- auto.controls.common_controls.StatusBarWrapper
auto.tests.allcontrols), 118 method), 98
always_wait_until() (in module pywinauto.timings), 74 build_condition() (pywinauto.uia_defines.IUIA method),
always_wait_until_passes() (in module pywin- 129
auto.timings), 74 build_unique_dict() (in module pywin-
AnimationWrapper (class in pywin- auto.findbestmatch), 70
auto.controls.common_controls), 92 Button() (pywinauto.controls.common_controls.ToolbarWrapper
Application (class in pywinauto.application), 65 method), 99
AppNotConnected, 65 button() (pywinauto.controls.common_controls.ToolbarWrapper
AppStartError, 65 method), 100
AsianHotkeyTest() (in module pywin- button() (pywinauto.controls.uia_controls.ToolbarWrapper
auto.tests.asianhotkey), 118 method), 116
assert_valid_process() (in module pywin- button_count() (pywin-
auto.application), 69 auto.controls.common_controls.ToolbarWrapper
AssertValidProcess() (in module pywinauto.application), method), 100
67 button_count() (pywin-
auto.controls.uia_controls.ToolbarWrapper

139
pywinauto Documentation, Release 0.6.8

method), 116 method), 104


ButtonCount() (pywinauto.controls.common_controls.ToolbarWrapper
check_by_click_input() (pywin-
method), 100 auto.controls.win32_controls.ButtonWrapper
buttons() (pywinauto.controls.uia_controls.ToolbarWrapper method), 104
method), 116 CheckButton() (pywin-
ButtonWrapper (class in pywin- auto.controls.common_controls.ToolbarWrapper
auto.controls.uia_controls), 111 method), 100
ButtonWrapper (class in pywin- CheckByClick() (pywin-
auto.controls.win32_controls), 103 auto.controls.win32_controls.ButtonWrapper
method), 104
C CheckByClickInput() (pywin-
calc_min_rectangle() (pywin- auto.controls.win32_controls.ButtonWrapper
auto.controls.common_controls.CalendarWrapper method), 104
method), 92 CheckGuardSignature() (pywin-
CalendarWrapper (class in pywin- auto.remote_memory_block.RemoteMemoryBlock
auto.controls.common_controls), 92 method), 133
can_be_label (pywinauto.base_wrapper.BaseWrapper at- child_window() (pywin-
tribute), 76 auto.application.WindowSpecification
can_be_label (pywinauto.controls.hwndwrapper.DialogWrapper method), 67
attribute), 81 children() (in module pywinauto.handleprops), 130
children()
can_be_label (pywinauto.controls.uia_controls.StaticWrapper (pywinauto.base_wrapper.BaseWrapper
attribute), 116 method), 76
children() (pywinauto.controls.common_controls._treeview_element
can_be_label (pywinauto.controls.win32_controls.ButtonWrapper
attribute), 104 method), 89
children()
can_be_label (pywinauto.controls.win32_controls.StaticWrapper (pywinauto.element_info.ElementInfo
attribute), 108 method), 125
can_select_multiple() (pywin- children() (pywinauto.uia_element_info.UIAElementInfo
auto.controls.uiawrapper.UIAWrapper method), 127
method), 108 children() (pywinauto.win32_element_info.HwndElementInfo
capture_as_image() (pywin- method), 126
auto.base_wrapper.BaseWrapper method), children_texts() (pywin-
76 auto.controls.uiawrapper.UIAWrapper
cell() (pywinauto.controls.uia_controls.ListViewWrapper method), 108
method), 114 class_name (pywinauto.element_info.ElementInfo
cells() (pywinauto.controls.uia_controls.ListViewWrapper attribute), 125
method), 114 class_name (pywinauto.uia_element_info.UIAElementInfo
check() (pywinauto.controls.common_controls._listview_item attribute), 127
method), 90 class_name (pywinauto.win32_element_info.HwndElementInfo
Check() (pywinauto.controls.common_controls.ListViewWrapper attribute), 126
method), 94 class_name() (pywinauto.base_wrapper.BaseWrapper
check() (pywinauto.controls.common_controls.ListViewWrapper method), 76
method), 95 classname() (in module pywinauto.handleprops), 130
Check() (pywinauto.controls.win32_controls.ButtonWrapperCleanUp() (pywinauto.remote_memory_block.RemoteMemoryBlock
method), 103 method), 133
check() (pywinauto.controls.win32_controls.ButtonWrapperclick() (in module pywinauto.mouse), 63
method), 104 click() (pywinauto.controls.common_controls._listview_item
check_button() (pywin- method), 91
auto.controls.common_controls.ToolbarWrapper click() (pywinauto.controls.common_controls._toolbar_button
method), 100 method), 89
check_button() (pywin- click() (pywinauto.controls.common_controls._treeview_element
auto.controls.uia_controls.ToolbarWrapper method), 89
method), 116 click() (pywinauto.controls.hwndwrapper.HwndWrapper
check_by_click() (pywin- method), 82
auto.controls.win32_controls.ButtonWrapper click() (pywinauto.controls.menuwrapper.MenuItem

140 Index
pywinauto Documentation, Release 0.6.8

method), 87 column_count() (pywin-


click() (pywinauto.controls.uia_controls.ButtonWrapper auto.controls.uia_controls.ListViewWrapper
method), 111 method), 114
click() (pywinauto.controls.win32_controls.ButtonWrapper column_widths() (pywin-
method), 104 auto.controls.common_controls.ListViewWrapper
click_input() (pywinauto.base_wrapper.BaseWrapper method), 95
method), 76 ColumnCount() (pywin-
click_input() (pywinauto.controls.common_controls._listview_item auto.controls.common_controls.ListViewWrapper
method), 91 method), 94
click_input() (pywinauto.controls.common_controls._toolbar_button
Columns() (pywinauto.controls.common_controls.ListViewWrapper
method), 89 method), 95
click_input() (pywinauto.controls.common_controls._treeview_element
columns() (pywinauto.controls.common_controls.ListViewWrapper
method), 89 method), 95
click_input() (pywinauto.controls.menuwrapper.MenuItem columns() (pywinauto.controls.uia_controls.ListViewWrapper
method), 88 method), 114
client_area_rect() (pywin- ColumnWidths() (pywin-
auto.controls.hwndwrapper.DialogWrapper auto.controls.common_controls.ListViewWrapper
method), 81 method), 95
client_rect() (pywinauto.controls.common_controls._treeview_element
ComboBoxDroppedHeightTest() (in module pywin-
method), 90 auto.tests.comboboxdroppedheight), 119
client_rect() (pywinauto.controls.hwndwrapper.HwndWrapper ComboBoxExWrapper (class in pywin-
method), 82 auto.controls.common_controls), 93
client_rects() (pywinauto.controls.common_controls.HeaderWrapper
ComboBoxWrapper (class in pywin-
method), 94 auto.controls.uia_controls), 112
client_rects() (pywinauto.controls.common_controls.StatusBarWrapper
ComboBoxWrapper (class in pywin-
method), 98 auto.controls.win32_controls), 105
client_rects() (pywinauto.controls.common_controls.TabControlWrapper
CompareToRefFontTest() (in module pywin-
method), 98 auto.tests.comparetoreffont), 119
client_rects() (pywinauto.controls.hwndwrapper.HwndWrapperconnect() (pywinauto.application.Application method),
method), 82 66
client_to_screen() (pywin- context_help_id() (pywin-
auto.base_wrapper.BaseWrapper method), auto.controls.hwndwrapper.HwndWrapper
77 method), 82
ClientAreaRect() (pywin- contexthelpid() (in module pywinauto.handleprops), 130
auto.controls.hwndwrapper.DialogWrapper control_count() (pywinauto.base_wrapper.BaseWrapper
method), 81 method), 77
clientrect() (in module pywinauto.handleprops), 130 control_id (pywinauto.element_info.ElementInfo at-
close() (pywinauto.controls.hwndwrapper.HwndWrapper tribute), 125
method), 82 control_id (pywinauto.uia_element_info.UIAElementInfo
close() (pywinauto.controls.uiawrapper.UIAWrapper attribute), 128
method), 108 control_id (pywinauto.win32_element_info.HwndElementInfo
close_alt_f4() (pywinauto.controls.hwndwrapper.HwndWrapper attribute), 126
method), 82 control_id() (pywinauto.base_wrapper.BaseWrapper
close_click() (pywinauto.controls.hwndwrapper.HwndWrapper method), 77
method), 82 control_type (pywinauto.uia_element_info.UIAElementInfo
collapse() (pywinauto.controls.common_controls._treeview_element attribute), 128
method), 90 control_type (pywinauto.win32_element_info.HwndElementInfo
collapse() (pywinauto.controls.uia_controls.ComboBoxWrapper attribute), 126
method), 112 control_type() (pywinauto.controls.hwndwrapper.HwndWrapper
collapse() (pywinauto.controls.uiawrapper.UIAWrapper method), 82
method), 108 controlid() (in module pywinauto.handleprops), 130
column_count() (pywin- ControlNotEnabled, 80
auto.controls.common_controls.ListViewWrapperControlNotVisible, 80
method), 95 ControlProps (class in pywinauto.controlproperties), 129

Index 141
pywinauto Documentation, Release 0.6.8

count() (pywinauto.controls.common_controls.CalendarWrapper method), 105


method), 92 dump_tree() (pywinauto.application.WindowSpecification
cpu_usage() (pywinauto.application.Application method), 67
method), 66 dump_window() (pywinauto.element_info.ElementInfo
method), 125
D dump_window() (pywin-
DateTimePickerWrapper (class in pywin- auto.uia_element_info.UIAElementInfo
auto.controls.common_controls), 93 method), 128
debug_message() (pywin- dump_window() (pywin-
auto.controls.hwndwrapper.HwndWrapper auto.win32_element_info.HwndElementInfo
method), 82 method), 127
dumpwindow() (in module pywinauto.handleprops), 130
Decrement() (pywinauto.controls.common_controls.UpDownWrapper
method), 103
E
decrement() (pywinauto.controls.common_controls.UpDownWrapper
method), 103 EditWrapper (class in pywinauto.controls.uia_controls),
Defaults() (pywinauto.timings.TimeConfig method), 73 112
defaults() (pywinauto.timings.TimeConfig method), 73 EditWrapper (class in pywin-
descendants() (pywinauto.base_wrapper.BaseWrapper auto.controls.win32_controls), 105
method), 77 element (pywinauto.uia_element_info.UIAElementInfo
descendants() (pywinauto.element_info.ElementInfo attribute), 128
method), 125 element_class (pywinauto.backend.BackendsRegistry at-
descendants() (pywinauto.uia_element_info.UIAElementInfo tribute), 125
method), 128 element_class() (in module pywinauto.backend), 125
descendants() (pywinauto.win32_element_info.HwndElementInfo
element_info (pywinauto.base_wrapper.BaseWrapper at-
method), 127 tribute), 77
deselect() (pywinauto.controls.common_controls._listview_item
ElementAmbiguousError, 70
method), 91 ElementInfo (class in pywinauto.element_info), 125
Deselect() (pywinauto.controls.common_controls.ListViewWrapper
ElementNotEnabled, 80
method), 95 ElementNotFoundError, 70
deselect() (pywinauto.controls.common_controls.ListViewWrapper
ElementNotVisible, 80
method), 95 elements_from_uia_array() (in module pywin-
DialogWrapper (class in pywin- auto.uia_element_info), 128
auto.controls.hwndwrapper), 80 EmptyClipboard() (in module pywinauto.clipboard), 75
disable() (in module pywinauto.actionlogger), 132 enable() (in module pywinauto.actionlogger), 132
double_click() (in module pywinauto.mouse), 63 enabled (pywinauto.element_info.ElementInfo attribute),
double_click() (pywinauto.controls.hwndwrapper.HwndWrapper 125
method), 83 enabled (pywinauto.uia_element_info.UIAElementInfo
double_click_input() (pywin- attribute), 128
auto.base_wrapper.BaseWrapper method), enabled (pywinauto.win32_element_info.HwndElementInfo
77 attribute), 127
drag_mouse() (pywinauto.controls.hwndwrapper.HwndWrapper ensure_accessible() (in module pywin-
method), 83 auto.controls.menuwrapper), 89
drag_mouse_input() (pywin- ensure_visible() (pywin-
auto.base_wrapper.BaseWrapper method), auto.controls.common_controls._listview_item
77 method), 91
draw_outline() (pywinauto.base_wrapper.BaseWrapper ensure_visible() (pywin-
method), 77 auto.controls.common_controls._treeview_element
drop() (pywinauto.controls.common_controls._treeview_element method), 90
method), 90 ensure_visible() (pywin-
dropped_rect() (pywin- auto.controls.common_controls.TreeViewWrapper
auto.controls.win32_controls.ComboBoxWrapper method), 102
method), 105 ensure_visible() (pywin-
DroppedRect() (pywin- auto.controls.uia_controls.TreeItemWrapper
auto.controls.win32_controls.ComboBoxWrapper method), 117

142 Index
pywinauto Documentation, Release 0.6.8

EnsureVisible() (pywin- 77
auto.controls.common_controls.TreeViewWrapperfriendly_class_name() (pywin-
method), 101 auto.controls.menuwrapper.MenuItem
enum_windows() (in module pywinauto.findwindows), method), 88
70 friendly_class_name() (pywin-
exists() (pywinauto.application.WindowSpecification auto.controls.uiawrapper.UIAWrapper
method), 67 method), 108
expand() (pywinauto.controls.common_controls._treeview_element
friendly_class_name() (pywin-
method), 90 auto.controls.win32_controls.ButtonWrapper
expand() (pywinauto.controls.uia_controls.ComboBoxWrapper method), 104
method), 112 friendlyclassname (pywin-
expand() (pywinauto.controls.uiawrapper.UIAWrapper auto.base_wrapper.BaseWrapper attribute),
method), 108 77
exstyle() (in module pywinauto.handleprops), 130 friendlyclassname (pywin-
exstyle() (pywinauto.controls.hwndwrapper.HwndWrapper auto.controls.common_controls.AnimationWrapper
method), 83 attribute), 92
friendlyclassname (pywin-
F auto.controls.common_controls.CalendarWrapper
Fast() (pywinauto.timings.TimeConfig method), 73 attribute), 92
fast() (pywinauto.timings.TimeConfig method), 73 friendlyclassname (pywin-
filter_with_depth() (pywin- auto.controls.common_controls.ComboBoxExWrapper
auto.element_info.ElementInfo static method), attribute), 93
126 friendlyclassname (pywin-
find_best_control_matches() (in module pywin- auto.controls.common_controls.DateTimePickerWrapper
auto.findbestmatch), 70 attribute), 93
find_best_match() (in module pywinauto.findbestmatch), friendlyclassname (pywin-
70 auto.controls.common_controls.HeaderWrapper
find_best_matches() (pywin- attribute), 94
auto.findbestmatch.UniqueDict method), friendlyclassname (pywin-
69 auto.controls.common_controls.HotkeyWrapper
find_element() (in module pywinauto.findwindows), 70 attribute), 94
find_elements() (in module pywinauto.findwindows), 70 friendlyclassname (pywin-
find_window() (in module pywinauto.findwindows), 71 auto.controls.common_controls.IPAddressWrapper
find_windows() (in module pywinauto.findwindows), 71 attribute), 94
find_wrapper() (pywinauto.base_wrapper.BaseMeta friendlyclassname (pywin-
static method), 76 auto.controls.common_controls.ListViewWrapper
find_wrapper() (pywin- attribute), 95
auto.controls.hwndwrapper.HwndMeta static friendlyclassname (pywin-
method), 81 auto.controls.common_controls.PagerWrapper
find_wrapper() (pywinauto.controls.uiawrapper.UiaMeta attribute), 96
static method), 111 friendlyclassname (pywin-
font() (in module pywinauto.handleprops), 130 auto.controls.common_controls.ProgressWrapper
font() (pywinauto.controls.hwndwrapper.HwndWrapper attribute), 97
method), 83 friendlyclassname (pywin-
fonts() (pywinauto.controls.hwndwrapper.HwndWrapper auto.controls.common_controls.ReBarWrapper
method), 83 attribute), 97
friendlyclassname
force_close() (pywinauto.controls.hwndwrapper.DialogWrapper (pywin-
method), 81 auto.controls.common_controls.StatusBarWrapper
framework_id (pywinauto.element_info.ElementInfo at- attribute), 98
tribute), 126 friendlyclassname (pywin-
framework_id (pywinauto.uia_element_info.UIAElementInfo auto.controls.common_controls.TabControlWrapper
attribute), 128 attribute), 98
friendly_class_name() (pywin- friendlyclassname (pywin-
auto.base_wrapper.BaseWrapper method), auto.controls.common_controls.ToolbarWrapper

Index 143
pywinauto Documentation, Release 0.6.8

attribute), 100 get_base() (pywinauto.controls.common_controls.UpDownWrapper


friendlyclassname (pywin- method), 103
auto.controls.common_controls.ToolTipsWrapperget_border() (pywinauto.controls.common_controls.CalendarWrapper
attribute), 99 method), 92
friendlyclassname (pywin- get_buddy_control() (pywin-
auto.controls.common_controls.TrackbarWrapper auto.controls.common_controls.UpDownWrapper
attribute), 101 method), 103
friendlyclassname (pywin- get_button() (pywinauto.controls.common_controls.ToolbarWrapper
auto.controls.common_controls.TreeViewWrapper method), 100
attribute), 102 get_button_rect() (pywin-
friendlyclassname (pywin- auto.controls.common_controls.ToolbarWrapper
auto.controls.common_controls.UpDownWrapper method), 100
attribute), 103 get_button_struct() (pywin-
friendlyclassname (pywin- auto.controls.common_controls.ToolbarWrapper
auto.controls.hwndwrapper.DialogWrapper method), 100
attribute), 81 get_channel_rect() (pywin-
friendlyclassname (pywin- auto.controls.common_controls.TrackbarWrapper
auto.controls.win32_controls.ButtonWrapper method), 101
attribute), 104 get_check_state() (pywin-
friendlyclassname (pywin- auto.controls.win32_controls.ButtonWrapper
auto.controls.win32_controls.ComboBoxWrapper method), 104
attribute), 105 get_child() (pywinauto.controls.common_controls._treeview_element
friendlyclassname (pywin- method), 90
auto.controls.win32_controls.EditWrapper get_child() (pywinauto.controls.uia_controls.TreeItemWrapper
attribute), 106 method), 117
friendlyclassname (pywin- get_column() (pywinauto.controls.common_controls.ListViewWrapper
auto.controls.win32_controls.ListBoxWrapper method), 95
attribute), 107 get_column() (pywinauto.controls.uia_controls.ListViewWrapper
friendlyclassname (pywin- method), 114
auto.controls.win32_controls.PopupMenuWrapperget_column_rectangle() (pywin-
attribute), 107 auto.controls.common_controls.HeaderWrapper
friendlyclassname (pywin- method), 94
auto.controls.win32_controls.StaticWrapper get_column_text() (pywin-
attribute), 108 auto.controls.common_controls.HeaderWrapper
from_point() (pywinauto.base_wrapper.BaseWrapper method), 94
method), 78 get_control_names() (in module pywin-
from_point() (pywinauto.uia_element_info.UIAElementInfo auto.findbestmatch), 70
class method), 128 get_current_date() (pywin-
from_point() (pywinauto.win32_element_info.HwndElementInfo auto.controls.common_controls.CalendarWrapper
class method), 127 method), 92
full_control_type (pywin- get_dialog_props_from_handle() (in module pywin-
auto.win32_element_info.HwndElementInfo auto.controls.hwndwrapper), 86
attribute), 127 get_elem_interface() (in module pywinauto.uia_defines),
full_control_type() (pywin- 129
auto.controls.hwndwrapper.HwndWrapper get_expand_state() (pywin-
method), 83 auto.controls.uia_controls.ComboBoxWrapper
FuncWrapper (class in pywinauto.controlproperties), 129 method), 112
FuzzyDict (class in pywinauto.fuzzydict), 132 get_expand_state() (pywin-
auto.controls.uiawrapper.UIAWrapper
G method), 109
get_active() (pywinauto.controls.hwndwrapper.HwndWrapperget_first_weekday() (pywin-
method), 83 auto.controls.common_controls.CalendarWrapper
get_band() (pywinauto.controls.common_controls.ReBarWrapper method), 92
method), 97 get_focus() (pywinauto.controls.hwndwrapper.HwndWrapper

144 Index
pywinauto Documentation, Release 0.6.8

method), 83 method), 101


get_header_control() (pywin- get_part_rect() (pywin-
auto.controls.common_controls.ListViewWrapper auto.controls.common_controls.StatusBarWrapper
method), 95 method), 98
get_header_control() (pywin- get_part_text() (pywin-
auto.controls.uia_controls.ListViewWrapper auto.controls.common_controls.StatusBarWrapper
method), 114 method), 98
get_header_controls() (pywin- get_position() (pywinauto.controls.common_controls.PagerWrapper
auto.controls.uia_controls.ListViewWrapper method), 96
method), 114 get_position() (pywinauto.controls.common_controls.ProgressWrapper
get_id() (pywinauto.controls.common_controls.CalendarWrapper method), 97
method), 92 get_position() (pywinauto.controls.common_controls.TrackbarWrapper
get_item() (pywinauto.controls.common_controls.ListViewWrapper method), 101
method), 95 get_properties() (pywinauto.base_wrapper.BaseWrapper
get_item() (pywinauto.controls.common_controls.TreeViewWrapper method), 78
method), 102 get_properties() (pywin-
get_item() (pywinauto.controls.uia_controls.ListViewWrapper auto.controls.common_controls.TabControlWrapper
method), 114 method), 98
get_item() (pywinauto.controls.uia_controls.TreeViewWrapper
get_properties() (pywin-
method), 117 auto.controls.common_controls.TreeViewWrapper
get_item_focus() (pywin- method), 102
auto.controls.win32_controls.ListBoxWrapper get_properties() (pywinauto.controls.menuwrapper.Menu
method), 107 method), 87
get_item_rect() (pywin- get_properties() (pywin-
auto.controls.common_controls.ListViewWrapper auto.controls.menuwrapper.MenuItem
method), 95 method), 88
get_item_rect() (pywin- get_properties() (pywin-
auto.controls.uia_controls.ListViewWrapper auto.controls.win32_controls.ComboBoxWrapper
method), 114 method), 105
get_items() (pywinauto.controls.uia_controls.ListViewWrapper
get_range() (pywinauto.controls.common_controls.UpDownWrapper
method), 114 method), 103
get_line() (pywinauto.controls.uia_controls.EditWrapper get_range_max() (pywin-
method), 112 auto.controls.common_controls.TrackbarWrapper
get_line() (pywinauto.controls.win32_controls.EditWrapper method), 101
method), 106 get_range_min() (pywin-
get_line_size() (pywin- auto.controls.common_controls.TrackbarWrapper
auto.controls.common_controls.TrackbarWrapper method), 101
method), 101 get_sel_end() (pywinauto.controls.common_controls.TrackbarWrapper
get_menu_path() (pywin- method), 101
auto.controls.menuwrapper.Menu method), get_sel_start() (pywinauto.controls.common_controls.TrackbarWrapper
87 method), 101
get_month_delta() (pywin- get_selected_count() (pywin-
auto.controls.common_controls.CalendarWrapper auto.controls.common_controls.ListViewWrapper
method), 92 method), 95
get_month_range() (pywin- get_selected_count() (pywin-
auto.controls.common_controls.CalendarWrapper auto.controls.uia_controls.ListViewWrapper
method), 92 method), 114
get_non_text_control_name() (in module pywin- get_selected_tab() (pywin-
auto.findbestmatch), 70 auto.controls.common_controls.TabControlWrapper
get_num_ticks() (pywin- method), 99
auto.controls.common_controls.TrackbarWrapperget_selected_tab() (pywin-
method), 101 auto.controls.uia_controls.TabControlWrapper
get_page_size() (pywin- method), 116
auto.controls.common_controls.TrackbarWrapperget_selection() (pywin-

Index 145
pywinauto Documentation, Release 0.6.8

auto.controls.uiawrapper.UIAWrapper auto.controls.common_controls.ToolbarWrapper
method), 109 method), 100
get_show_state() (pywin- GetButtonStruct() (pywin-
auto.controls.hwndwrapper.HwndWrapper auto.controls.common_controls.ToolbarWrapper
method), 83 method), 100
get_show_state() (pywin- GetCheckState() (pywin-
auto.controls.uiawrapper.UIAWrapper auto.controls.win32_controls.ButtonWrapper
method), 109 method), 104
get_state() (pywinauto.controls.common_controls.ProgressWrapper
GetClipboardFormats() (in module pywinauto.clipboard),
method), 97 75
get_step() (pywinauto.controls.common_controls.ProgressWrapper
GetColumn() (pywinauto.controls.common_controls.ListViewWrapper
method), 97 method), 95
get_tab_rect() (pywinauto.controls.common_controls.TabControlWrapper
GetColumnRectangle() (pywin-
method), 99 auto.controls.common_controls.HeaderWrapper
get_tab_text() (pywinauto.controls.common_controls.TabControlWrapper
method), 94
method), 99 GetColumnText() (pywin-
get_time() (pywinauto.controls.common_controls.DateTimePickerWrapper
auto.controls.common_controls.HeaderWrapper
method), 93 method), 94
get_tip() (pywinauto.controls.common_controls.ToolTipsWrapper
GetData() (in module pywinauto.clipboard), 75
method), 99 GetFormatName() (in module pywinauto.clipboard), 75
get_tip_text() (pywinauto.controls.common_controls.ToolTipsWrapper
GetHeaderControl() (pywin-
method), 99 auto.controls.common_controls.ListViewWrapper
get_today() (pywinauto.controls.common_controls.CalendarWrapper method), 95
method), 92 GetHotkey() (in module pywinauto.tests.repeatedhotkey),
get_toggle_state() (pywin- 123
auto.controls.uia_controls.ButtonWrapper GetItem() (pywinauto.controls.common_controls.ListViewWrapper
method), 111 method), 95
get_tool_tips_control() (pywin- GetItem() (pywinauto.controls.common_controls.TreeViewWrapper
auto.controls.common_controls.ReBarWrapper method), 101
method), 97 GetItemFocus() (pywin-
get_tool_tips_control() (pywin- auto.controls.win32_controls.ListBoxWrapper
auto.controls.common_controls.ToolbarWrapper method), 106
method), 100 GetItemRect() (pywinauto.controls.common_controls.ListViewWrapper
get_toolbar() (pywinauto.controls.hwndwrapper.HwndWrapper method), 95
method), 83 GetLeadSpaces() (in module pywin-
get_tooltips_control() (pywin- auto.tests.leadtrailspaces), 120
auto.controls.common_controls.TrackbarWrapperGetLine() (pywinauto.controls.win32_controls.EditWrapper
method), 101 method), 105
get_value() (pywinauto.controls.common_controls.UpDownWrapper
GetMatchHistoryItem() (pywin-
method), 103 auto.application.Application method), 65
get_value() (pywinauto.controls.uia_controls.EditWrapper GetMenuBlocks() (in module pywin-
method), 112 auto.controlproperties), 129
get_view() (pywinauto.controls.common_controls.CalendarWrapper
GetPartRect() (pywinauto.controls.common_controls.StatusBarWrapper
method), 92 method), 98
GetBand() (pywinauto.controls.common_controls.ReBarWrapper
GetPartText() (pywinauto.controls.common_controls.StatusBarWrapper
method), 97 method), 98
GetBase() (pywinauto.controls.common_controls.UpDownWrapper
GetPosition() (pywinauto.controls.common_controls.PagerWrapper
method), 103 method), 96
GetBuddyControl() (pywin- GetPosition() (pywinauto.controls.common_controls.ProgressWrapper
auto.controls.common_controls.UpDownWrapper method), 96
method), 103 GetRange() (pywinauto.controls.common_controls.UpDownWrapper
GetButton() (pywinauto.controls.common_controls.ToolbarWrapper method), 103
method), 100 GetSelectedCount() (pywin-
GetButtonRect() (pywin- auto.controls.common_controls.ListViewWrapper

146 Index
pywinauto Documentation, Release 0.6.8

method), 95 method), 109


GetSelectedTab() (pywin- has_style() (in module pywinauto.handleprops), 130
auto.controls.common_controls.TabControlWrapper
has_style() (pywinauto.controlproperties.ControlProps
method), 98 method), 129
GetState() (pywinauto.controls.common_controls.ProgressWrapper
has_style() (pywinauto.controls.common_controls._toolbar_button
method), 97 method), 89
GetStep() (pywinauto.controls.common_controls.ProgressWrapper
has_style() (pywinauto.controls.hwndwrapper.HwndWrapper
method), 97 method), 84
GetTabRect() (pywinauto.controls.common_controls.TabControlWrapper
has_title (pywinauto.base_wrapper.BaseWrapper at-
method), 98 tribute), 78
GetTabText() (pywinauto.controls.common_controls.TabControlWrapper
has_title (pywinauto.controls.common_controls.CalendarWrapper
method), 98 attribute), 92
GetTime() (pywinauto.controls.common_controls.DateTimePickerWrapper
has_title (pywinauto.controls.common_controls.ComboBoxExWrapper
method), 93 attribute), 93
GetTip() (pywinauto.controls.common_controls.ToolTipsWrapper
has_title (pywinauto.controls.common_controls.DateTimePickerWrapper
method), 99 attribute), 93
GetTipText() (pywinauto.controls.common_controls.ToolTipsWrapper
has_title (pywinauto.controls.common_controls.HotkeyWrapper
method), 99 attribute), 94
GetToolTipsControl() (pywin- has_title (pywinauto.controls.common_controls.IPAddressWrapper
auto.controls.common_controls.ReBarWrapper attribute), 94
method), 97 has_title (pywinauto.controls.common_controls.ProgressWrapper
GetToolTipsControl() (pywin- attribute), 97
auto.controls.common_controls.ToolbarWrapper has_title (pywinauto.controls.uia_controls.EditWrapper
method), 100 attribute), 113
GetTrailSpaces() (in module pywin- has_title (pywinauto.controls.uia_controls.SliderWrapper
auto.tests.leadtrailspaces), 120 attribute), 115
GetValue() (pywinauto.controls.common_controls.UpDownWrapper
has_title (pywinauto.controls.win32_controls.ComboBoxWrapper
method), 103 attribute), 105
has_title (pywinauto.controls.win32_controls.EditWrapper
H attribute), 106
handle (pywinauto.controls.hwndwrapper.HwndWrapper has_title (pywinauto.controls.win32_controls.ListBoxWrapper
attribute), 83 attribute), 107
handle (pywinauto.element_info.ElementInfo attribute), has_title (pywinauto.controls.win32_controls.PopupMenuWrapper
126 attribute), 107
handle (pywinauto.uia_element_info.UIAElementInfo at- HasExStyle() (pywinauto.controlproperties.ControlProps
tribute), 128 method), 129
handle (pywinauto.win32_element_info.HwndElementInfo HasStyle() (pywinauto.controlproperties.ControlProps
attribute), 127 method), 129
has_depth() (pywinauto.element_info.ElementInfo HeaderItemWrapper (class in pywin-
method), 126 auto.controls.uia_controls), 113
has_enough_privileges() (in module pywin- HeaderWrapper (class in pywin-
auto.handleprops), 130 auto.controls.common_controls), 94
has_exstyle() (in module pywinauto.handleprops), 130 HeaderWrapper (class in pywin-
has_exstyle() (pywinauto.controlproperties.ControlProps auto.controls.uia_controls), 113
method), 129 hide_from_taskbar() (pywin-
has_exstyle() (pywinauto.controls.hwndwrapper.HwndWrapper auto.controls.hwndwrapper.DialogWrapper
method), 83 method), 81
has_focus() (pywinauto.controls.hwndwrapper.HwndWrapper HideFromTaskbar() (pywin-
method), 83 auto.controls.hwndwrapper.DialogWrapper
has_keyboard_focus() (pywin- method), 81
auto.controls.hwndwrapper.HwndWrapper hit_test() (pywinauto.controls.common_controls.CalendarWrapper
method), 84 method), 92
has_keyboard_focus() (pywin- Hook (class in pywinauto.win32_hooks), 75
auto.controls.uiawrapper.UIAWrapper hook() (pywinauto.win32_hooks.Hook method), 75

Index 147
pywinauto Documentation, Release 0.6.8

HotkeyWrapper (class in pywin- iface_virtualized_item (pywin-


auto.controls.common_controls), 94 auto.controls.uiawrapper.UIAWrapper at-
HwndElementInfo (class in pywin- tribute), 109
auto.win32_element_info), 126 iface_window (pywinauto.controls.uiawrapper.UIAWrapper
HwndMeta (class in pywinauto.controls.hwndwrapper), attribute), 110
81 image() (pywinauto.controls.common_controls._listview_item
HwndWrapper (class in pywin- method), 91
auto.controls.hwndwrapper), 81 ImplementsHotkey() (in module pywin-
auto.tests.repeatedhotkey), 123
I Increment() (pywinauto.controls.common_controls.UpDownWrapper
iface_expand_collapse (pywin- method), 103
auto.controls.uiawrapper.UIAWrapper at- increment() (pywinauto.controls.common_controls.UpDownWrapper
tribute), 109 method), 103
iface_grid (pywinauto.controls.uiawrapper.UIAWrapper indent() (pywinauto.controls.common_controls._listview_item
attribute), 109 method), 91
iface_grid_item (pywin- index() (pywinauto.controls.menuwrapper.MenuItem
auto.controls.uiawrapper.UIAWrapper at- method), 88
tribute), 109 inplace_control() (pywin-
iface_invoke (pywinauto.controls.uiawrapper.UIAWrapper auto.controls.common_controls._listview_item
attribute), 109 method), 91
iface_item_container (pywin- InvalidElement, 80
auto.controls.uiawrapper.UIAWrapper at- InvalidWindowHandle, 86
tribute), 109 invoke() (pywinauto.controls.uiawrapper.UIAWrapper
iface_range_value (pywin- method), 110
auto.controls.uiawrapper.UIAWrapper at- IPAddressWrapper (class in pywin-
tribute), 109 auto.controls.common_controls), 94
iface_scroll (pywinauto.controls.uiawrapper.UIAWrapper is64bit() (pywinauto.application.Application method), 66
attribute), 109 is64bitbinary() (in module pywinauto.handleprops), 130
iface_scroll_item (pywin- is64bitprocess() (in module pywinauto.handleprops), 130
auto.controls.uiawrapper.UIAWrapper at- is_above_or_to_left() (in module pywin-
tribute), 109 auto.findbestmatch), 70
iface_selection (pywin- is_active() (pywinauto.controls.hwndwrapper.HwndWrapper
auto.controls.uiawrapper.UIAWrapper at- method), 84
tribute), 109 is_active() (pywinauto.controls.uiawrapper.UIAWrapper
iface_selection_item (pywin- method), 110
auto.controls.uiawrapper.UIAWrapper at- is_checkable() (pywinauto.controls.common_controls._toolbar_button
tribute), 109 method), 89
iface_table (pywinauto.controls.uiawrapper.UIAWrapper is_checked() (pywinauto.controls.common_controls._listview_item
attribute), 109 method), 91
iface_table_item (pywin- is_checked() (pywinauto.controls.common_controls._toolbar_button
auto.controls.uiawrapper.UIAWrapper at- method), 89
tribute), 109 is_checked() (pywinauto.controls.common_controls._treeview_element
iface_text (pywinauto.controls.uiawrapper.UIAWrapper method), 90
attribute), 109 is_checked() (pywinauto.controls.common_controls.ListViewWrapper
iface_toggle (pywinauto.controls.uiawrapper.UIAWrapper method), 96
attribute), 109 is_checked() (pywinauto.controls.menuwrapper.MenuItem
iface_transform (pywin- method), 88
auto.controls.uiawrapper.UIAWrapper at- is_checked() (pywinauto.controls.uia_controls.ListItemWrapper
tribute), 109 method), 113
iface_transformV2 (pywin- is_checked() (pywinauto.controls.uia_controls.TreeItemWrapper
auto.controls.uiawrapper.UIAWrapper at- method), 117
tribute), 109 is_checked() (pywinauto.controls.win32_controls.ButtonWrapper
iface_value (pywinauto.controls.uiawrapper.UIAWrapper method), 104
attribute), 109 is_child() (pywinauto.base_wrapper.BaseWrapper

148 Index
pywinauto Documentation, Release 0.6.8

method), 78 is_normal() (pywinauto.controls.uiawrapper.UIAWrapper


is_collapsed() (pywinauto.controls.uiawrapper.UIAWrapper method), 110
method), 110 is_pressable() (pywinauto.controls.common_controls._toolbar_button
is_dialog() (pywinauto.base_wrapper.BaseWrapper method), 89
method), 78 is_pressed() (pywinauto.controls.common_controls._toolbar_button
is_dialog() (pywinauto.controls.hwndwrapper.HwndWrapper method), 89
method), 84 is_process_running() (pywinauto.application.Application
is_dialog() (pywinauto.controls.uia_controls.ButtonWrapper method), 66
method), 112 is_selected() (pywinauto.controls.common_controls._listview_item
is_dialog() (pywinauto.controls.uiawrapper.UIAWrapper method), 91
method), 110 is_selected() (pywinauto.controls.common_controls._treeview_element
is_dialog() (pywinauto.controls.win32_controls.ButtonWrapper method), 90
method), 104 is_selected() (pywinauto.controls.common_controls.ListViewWrapper
is_dialog() (pywinauto.controls.win32_controls.PopupMenuWrapper method), 96
method), 107 is_selected() (pywinauto.controls.common_controls.TreeViewWrapper
is_editable() (pywinauto.controls.uia_controls.ComboBoxWrapper method), 102
method), 112 is_selected() (pywinauto.controls.uiawrapper.UIAWrapper
is_editable() (pywinauto.controls.uia_controls.EditWrapper method), 110
method), 113 is_selection_required() (pywin-
is_enabled() (pywinauto.base_wrapper.BaseWrapper auto.controls.uiawrapper.UIAWrapper
method), 78 method), 110
is_enabled() (pywinauto.controls.common_controls._toolbar_button
is_single_selection() (pywin-
method), 89 auto.controls.win32_controls.ListBoxWrapper
is_enabled() (pywinauto.controls.menuwrapper.MenuItem method), 107
method), 88 is_toplevel_window() (in module pywin-
is_expanded() (pywinauto.controls.common_controls._treeview_element auto.handleprops), 130
method), 90 is_unicode() (pywinauto.controls.hwndwrapper.HwndWrapper
is_expanded() (pywinauto.controls.uiawrapper.UIAWrapper method), 84
method), 110 is_visible() (pywinauto.base_wrapper.BaseWrapper
is_focused() (pywinauto.controls.common_controls._listview_item method), 78
method), 91 is_x64_OS() (in module pywinauto.sysinfo), 132
is_focused() (pywinauto.controls.common_controls.ListViewWrapper
is_x64_Python() (in module pywinauto.sysinfo), 132
method), 96 isenabled() (in module pywinauto.handleprops), 130
is_hooked() (pywinauto.win32_hooks.Hook method), 75 IsFocused() (pywinauto.controls.common_controls.ListViewWrapper
is_in_taskbar() (pywin- method), 95
auto.controls.hwndwrapper.DialogWrapper IsInTaskbar() (pywinauto.controls.hwndwrapper.DialogWrapper
method), 81 method), 81
is_keyboard_focusable() (pywin- IsSelected() (pywinauto.controls.common_controls.ListViewWrapper
auto.controls.uiawrapper.UIAWrapper method), 95
method), 110 IsSelected() (pywinauto.controls.common_controls.TreeViewWrapper
is_maximized() (pywin- method), 101
auto.controls.hwndwrapper.HwndWrapper IsSingleSelection() (pywin-
method), 84 auto.controls.win32_controls.ListBoxWrapper
is_maximized() (pywin- method), 106
auto.controls.uiawrapper.UIAWrapper isunicode() (in module pywinauto.handleprops), 130
method), 110 isvisible() (in module pywinauto.handleprops), 130
is_minimized() (pywin- iswindow() (in module pywinauto.handleprops), 131
auto.controls.hwndwrapper.HwndWrapper item() (pywinauto.controls.common_controls._listview_item
method), 84 method), 91
is_minimized() (pywin- item() (pywinauto.controls.common_controls._treeview_element
auto.controls.uiawrapper.UIAWrapper method), 90
method), 110 Item() (pywinauto.controls.common_controls.ListViewWrapper
is_normal() (pywinauto.controls.hwndwrapper.HwndWrapper method), 95
method), 84 item() (pywinauto.controls.common_controls.ListViewWrapper

Index 149
pywinauto Documentation, Release 0.6.8

method), 96 method), 102


Item() (pywinauto.controls.common_controls.TreeViewWrapper
ItemCount() (pywinauto.controls.win32_controls.ComboBoxWrapper
method), 102 method), 105
item() (pywinauto.controls.common_controls.TreeViewWrapper
ItemCount() (pywinauto.controls.win32_controls.ListBoxWrapper
method), 102 method), 106
item() (pywinauto.controls.menuwrapper.Menu method), ItemData() (pywinauto.controls.win32_controls.ComboBoxWrapper
87 method), 105
item() (pywinauto.controls.uia_controls.ListViewWrapper ItemData() (pywinauto.controls.win32_controls.ListBoxWrapper
method), 114 method), 107
item_by_index() (pywin- ItemRect() (pywinauto.controls.win32_controls.ListBoxWrapper
auto.controls.uia_controls.MenuWrapper method), 107
method), 115 Items() (pywinauto.controls.common_controls.ListViewWrapper
item_by_path() (pywin- method), 95
auto.controls.uia_controls.MenuWrapper items() (pywinauto.controls.common_controls.ListViewWrapper
method), 115 method), 96
item_count() (pywinauto.controls.common_controls.HeaderWrapper
items() (pywinauto.controls.menuwrapper.Menu
method), 94 method), 87
item_count() (pywinauto.controls.common_controls.ListViewWrapper
items() (pywinauto.controls.uia_controls.ListViewWrapper
method), 96 method), 114
item_count() (pywinauto.controls.common_controls.TreeViewWrapper
items() (pywinauto.controls.uia_controls.MenuItemWrapper
method), 102 method), 115
item_count() (pywinauto.controls.menuwrapper.Menu items() (pywinauto.controls.uia_controls.MenuWrapper
method), 87 method), 115
item_count() (pywinauto.controls.uia_controls.ComboBoxWrapper
ItemTexts() (pywinauto.controls.win32_controls.ComboBoxWrapper
method), 112 method), 105
item_count() (pywinauto.controls.uia_controls.ListViewWrapper
ItemTexts() (pywinauto.controls.win32_controls.ListBoxWrapper
method), 114 method), 107
item_count() (pywinauto.controls.uia_controls.TreeViewWrapper
iter_children() (pywinauto.base_wrapper.BaseWrapper
method), 117 method), 78
item_count() (pywinauto.controls.win32_controls.ComboBoxWrapper
iter_children() (pywinauto.element_info.ElementInfo
method), 105 method), 126
item_count() (pywinauto.controls.win32_controls.ListBoxWrapper
iter_children() (pywinauto.uia_element_info.UIAElementInfo
method), 107 method), 128
item_data() (pywinauto.controls.common_controls._listview_item
iter_children() (pywinauto.win32_element_info.HwndElementInfo
method), 91 method), 127
item_data() (pywinauto.controls.win32_controls.ComboBoxWrapper
iter_descendants() (pywin-
method), 105 auto.base_wrapper.BaseWrapper method),
item_data() (pywinauto.controls.win32_controls.ListBoxWrapper 78
method), 107 iter_descendants() (pywinauto.element_info.ElementInfo
item_id() (pywinauto.controls.menuwrapper.MenuItem method), 126
method), 88 IUIA (class in pywinauto.uia_defines), 129
item_rect() (pywinauto.controls.win32_controls.ListBoxWrapper
method), 107 K
item_texts() (pywinauto.controls.win32_controls.ComboBoxWrapper
KeyboardEvent (class in pywinauto.win32_hooks), 76
method), 105 kill() (pywinauto.application.Application method), 66
item_texts() (pywinauto.controls.win32_controls.ListBoxWrapper
method), 107 L
item_type() (pywinauto.controls.menuwrapper.MenuItem large_change() (pywin-
method), 88 auto.controls.uia_controls.SliderWrapper
ItemCount() (pywinauto.controls.common_controls.HeaderWrapper method), 115
method), 94 lazy_property (in module pywin-
ItemCount() (pywinauto.controls.common_controls.ListViewWrapperauto.controls.uiawrapper), 111
method), 95 LazyProperty (class in pywinauto.controls.uiawrapper),
ItemCount() (pywinauto.controls.common_controls.TreeViewWrapper108

150 Index
pywinauto Documentation, Release 0.6.8

LeadTrailSpacesTest() (in module pywin- MenuInaccessible, 87


auto.tests.leadtrailspaces), 120 MenuInfo (class in pywinauto.controls.menuwrapper), 87
legacy_properties() (pywin- MenuItem (class in pywinauto.controls.menuwrapper),
auto.controls.uiawrapper.UIAWrapper 87
method), 110 MenuItemAsControl() (in module pywin-
line_count() (pywinauto.controls.uia_controls.EditWrapper auto.controlproperties), 129
method), 113 MenuItemInfo (class in pywin-
line_count() (pywinauto.controls.win32_controls.EditWrapper auto.controls.menuwrapper), 88
method), 106 MenuItemNotEnabled, 88
line_length() (pywinauto.controls.uia_controls.EditWrapperMenuItemWrapper (class in pywin-
method), 113 auto.controls.uia_controls), 115
line_length() (pywinauto.controls.win32_controls.EditWrapper
MenuWrapper (class in pywinauto.controls.uia_controls),
method), 106 115
LineCount() (pywinauto.controls.win32_controls.EditWrappermin_value() (pywinauto.controls.uia_controls.SliderWrapper
method), 106 method), 115
LineLength() (pywinauto.controls.win32_controls.EditWrapper
minimize() (pywinauto.controls.hwndwrapper.HwndWrapper
method), 106 method), 84
ListBoxWrapper (class in pywin- minimize() (pywinauto.controls.uiawrapper.UIAWrapper
auto.controls.win32_controls), 106 method), 111
listen() (pywinauto.win32_hooks.Hook method), 75 MiscValuesTest() (in module pywin-
ListItemWrapper (class in pywin- auto.tests.miscvalues), 121
auto.controls.uia_controls), 113 MissalignmentTest() (in module pywin-
ListViewWrapper (class in pywin- auto.tests.missalignment), 121
auto.controls.common_controls), 94 MissingExtraStringTest() (in module pywin-
ListViewWrapper (class in pywin- auto.tests.missingextrastring), 122
auto.controls.uia_controls), 113 MouseEvent (class in pywinauto.win32_hooks), 76
move() (in module pywinauto.mouse), 63
M move_mouse() (pywin-
MatchError, 69 auto.controls.hwndwrapper.HwndWrapper
max_value() (pywinauto.controls.uia_controls.SliderWrapper method), 84
method), 115 move_mouse_input() (pywin-
maximize() (pywinauto.controls.hwndwrapper.HwndWrapper auto.base_wrapper.BaseWrapper method),
method), 84 78
maximize() (pywinauto.controls.uiawrapper.UIAWrapper move_window() (pywin-
method), 110 auto.controls.hwndwrapper.HwndWrapper
Menu (class in pywinauto.controls.menuwrapper), 87 method), 84
menu() (pywinauto.controls.hwndwrapper.HwndWrapper
method), 84 N
menu_bar_click_input() (pywin- name (pywinauto.backend.BackendsRegistry attribute),
auto.controls.common_controls.ToolbarWrapper 125
method), 100 name (pywinauto.element_info.ElementInfo attribute),
menu_item() (pywinauto.controls.hwndwrapper.HwndWrapper 126
method), 84 name (pywinauto.uia_element_info.UIAElementInfo at-
menu_items() (pywinauto.controls.hwndwrapper.HwndWrapper tribute), 128
method), 84 name (pywinauto.win32_element_info.HwndElementInfo
menu_select() (pywinauto.controls.hwndwrapper.HwndWrapper attribute), 127
method), 84 name() (in module pywinauto.backend), 125
menu_select() (pywinauto.controls.uiawrapper.UIAWrappernext_item() (pywinauto.controls.common_controls._treeview_element
method), 110 method), 90
MenuBarClickInput() (pywin- NoPatternInterfaceError, 129
auto.controls.common_controls.ToolbarWrapper notify_parent() (pywin-
method), 100 auto.controls.hwndwrapper.HwndWrapper
MenuBlockAsControls() (in module pywin- method), 85
auto.controlproperties), 129

Index 151
pywinauto Documentation, Release 0.6.8

O print_control_identifiers() (pywin-
OptRect (class in pywinauto.tests.overlapping), 123 auto.application.WindowSpecification
os_arch() (in module pywinauto.sysinfo), 132 method), 68
OverlappingTest() (in module pywin- print_ctrl_ids() (pywin-
auto.tests.overlapping), 123 auto.application.WindowSpecification
owner() (pywinauto.controls.hwndwrapper.HwndWrapper method), 68
method), 85 print_items() (pywinauto.controls.common_controls.TreeViewWrapper
method), 102
P print_items() (pywinauto.controls.uia_controls.TreeViewWrapper
PagerWrapper (class in pywin- method), 117
auto.controls.common_controls), 96 PrintItems() (pywinauto.controls.common_controls.TreeViewWrapper
parent (pywinauto.element_info.ElementInfo attribute), method), 102
126 process_from_module() (in module pywin-
parent (pywinauto.uia_element_info.UIAElementInfo at- auto.application), 69
tribute), 128 process_get_modules() (in module pywin-
parent (pywinauto.win32_element_info.HwndElementInfo auto.application), 69
attribute), 127 process_id (pywinauto.element_info.ElementInfo at-
parent() (in module pywinauto.handleprops), 131 tribute), 126
parent() (pywinauto.base_wrapper.BaseWrapper process_id (pywinauto.uia_element_info.UIAElementInfo
method), 78 attribute), 128
process_id
part_count() (pywinauto.controls.common_controls.StatusBarWrapper (pywinauto.win32_element_info.HwndElementInfo
method), 98 attribute), 127
part_right_edges() (pywin- process_id() (pywinauto.base_wrapper.BaseWrapper
auto.controls.common_controls.StatusBarWrapper method), 79
method), 98 process_module() (in module pywinauto.application), 69
processid()
PartCount() (pywinauto.controls.common_controls.StatusBarWrapper (in module pywinauto.handleprops), 131
method), 98 ProcessNotFoundError, 67
PartRightEdges() (pywin- ProgressWrapper (class in pywin-
auto.controls.common_controls.StatusBarWrapper auto.controls.common_controls), 96
method), 98 python_bitness() (in module pywinauto.sysinfo), 132
place_in_calendar (pywin- pywinauto.actionlogger (module), 132
auto.controls.common_controls.CalendarWrapperpywinauto.application (module), 65
attribute), 92 pywinauto.backend (module), 125
popup_window() (pywin- pywinauto.base_wrapper (module), 76
auto.controls.hwndwrapper.HwndWrapper pywinauto.clipboard (module), 75
method), 85 pywinauto.controlproperties (module), 129
PopupMenuWrapper (class in pywin- pywinauto.controls.common_controls (module), 89
auto.controls.win32_controls), 107 pywinauto.controls.hwndwrapper (module), 80
post_command() (pywin- pywinauto.controls.menuwrapper (module), 87
auto.controls.hwndwrapper.HwndWrapper pywinauto.controls.uia_controls (module), 111
method), 85 pywinauto.controls.uiawrapper (module), 108
post_message() (pywin- pywinauto.controls.win32_controls (module), 103
auto.controls.hwndwrapper.HwndWrapper pywinauto.element_info (module), 125
method), 85 pywinauto.findbestmatch (module), 69
press() (in module pywinauto.mouse), 63 pywinauto.findwindows (module), 70
pywinauto.fuzzydict (module), 131
press_button() (pywinauto.controls.common_controls.ToolbarWrapper
method), 100 pywinauto.handleprops (module), 130
press_mouse() (pywinauto.controls.hwndwrapper.HwndWrapperpywinauto.keyboard (module), 63
method), 85 pywinauto.mouse (module), 63
press_mouse_input() (pywin- pywinauto.remote_memory_block (module), 132
auto.base_wrapper.BaseWrapper method), pywinauto.sysinfo (module), 132
79 pywinauto.tests.allcontrols (module), 117
pywinauto.tests.asianhotkey (module), 118
PressButton() (pywinauto.controls.common_controls.ToolbarWrapper
method), 100 pywinauto.tests.comboboxdroppedheight (module), 119

152 Index
pywinauto Documentation, Release 0.6.8

pywinauto.tests.comparetoreffont (module), 119 restore() (pywinauto.controls.hwndwrapper.HwndWrapper


pywinauto.tests.leadtrailspaces (module), 120 method), 85
pywinauto.tests.miscvalues (module), 120 restore() (pywinauto.controls.uiawrapper.UIAWrapper
pywinauto.tests.missalignment (module), 121 method), 111
pywinauto.tests.missingextrastring (module), 121 rich_text (pywinauto.element_info.ElementInfo at-
pywinauto.tests.overlapping (module), 122 tribute), 126
pywinauto.tests.repeatedhotkey (module), 123 rich_text (pywinauto.uia_element_info.UIAElementInfo
pywinauto.tests.translation (module), 123 attribute), 128
pywinauto.tests.truncation (module), 124 rich_text (pywinauto.win32_element_info.HwndElementInfo
pywinauto.timings (module), 72 attribute), 127
pywinauto.uia_defines (module), 129 right_click() (in module pywinauto.mouse), 63
pywinauto.uia_element_info (module), 127 right_click() (pywinauto.controls.hwndwrapper.HwndWrapper
pywinauto.win32_element_info (module), 126 method), 85
pywinauto.win32_hooks (module), 75 right_click_input() (pywin-
pywinauto.xml_helpers (module), 131 auto.base_wrapper.BaseWrapper method),
79
R root() (pywinauto.base_wrapper.BaseWrapper method),
Read() (pywinauto.remote_memory_block.RemoteMemoryBlock 79
method), 133 Root() (pywinauto.controls.common_controls.TreeViewWrapper
ReadPropertiesFromFile() (in module pywin- method), 102
auto.xml_helpers), 131 Roots() (pywinauto.controls.common_controls.TreeViewWrapper
ReBarWrapper (class in pywin- method), 102
auto.controls.common_controls), 97 roots() (pywinauto.controls.common_controls.TreeViewWrapper
rectangle (pywinauto.element_info.ElementInfo at- method), 102
tribute), 126 roots() (pywinauto.controls.uia_controls.TreeViewWrapper
rectangle (pywinauto.uia_element_info.UIAElementInfo method), 117
attribute), 128 row_count() (pywinauto.controls.common_controls.TabControlWrapper
rectangle (pywinauto.win32_element_info.HwndElementInfo method), 99
attribute), 127 RowCount() (pywinauto.controls.common_controls.TabControlWrapper
rectangle() (in module pywinauto.handleprops), 131 method), 98
rectangle() (pywinauto.base_wrapper.BaseWrapper run_tests() (pywinauto.controls.hwndwrapper.DialogWrapper
method), 79 method), 81
RunTests() (pywinauto.controls.hwndwrapper.DialogWrapper
rectangle() (pywinauto.controls.common_controls._listview_item
method), 91 method), 81
runtime_id (pywinauto.uia_element_info.UIAElementInfo
rectangle() (pywinauto.controls.common_controls._toolbar_button
method), 89 attribute), 128
rectangle() (pywinauto.controls.menuwrapper.MenuItem
method), 88 S
register() (in module pywinauto.backend), 125 scroll() (in module pywinauto.mouse), 63
release() (in module pywinauto.mouse), 63 scroll() (pywinauto.controls.hwndwrapper.HwndWrapper
release_mouse() (pywin- method), 85
auto.controls.hwndwrapper.HwndWrapper scroll() (pywinauto.controls.uiawrapper.UIAWrapper
method), 85 method), 111
release_mouse_input() (pywin- select() (pywinauto.controls.common_controls._listview_item
auto.base_wrapper.BaseWrapper method), method), 91
79 select() (pywinauto.controls.common_controls._treeview_element
RemoteMemoryBlock (class in pywin- method), 90
auto.remote_memory_block), 132 Select() (pywinauto.controls.common_controls.ListViewWrapper
remove_non_alphanumeric_symbols() (in module pywin- method), 95
auto.base_wrapper), 80 select() (pywinauto.controls.common_controls.ListViewWrapper
RepeatedHotkeyTest() (in module pywin- method), 96
auto.tests.repeatedhotkey), 123 Select() (pywinauto.controls.common_controls.TabControlWrapper
reset_level() (in module pywinauto.actionlogger), 132 method), 98

Index 153
pywinauto Documentation, Release 0.6.8

select() (pywinauto.controls.common_controls.TabControlWrapper
selection_indices() (pywin-
method), 99 auto.controls.uia_controls.EditWrapper
Select() (pywinauto.controls.common_controls.TreeViewWrapper method), 113
method), 102 selection_indices() (pywin-
select() (pywinauto.controls.common_controls.TreeViewWrapper auto.controls.win32_controls.EditWrapper
method), 102 method), 106
select() (pywinauto.controls.menuwrapper.MenuItem SelectionIndices() (pywin-
method), 88 auto.controls.win32_controls.EditWrapper
select() (pywinauto.controls.uia_controls.ComboBoxWrapper method), 106
method), 112 send_chars() (pywinauto.controls.hwndwrapper.HwndWrapper
select() (pywinauto.controls.uia_controls.EditWrapper method), 85
method), 113 send_command() (pywin-
select() (pywinauto.controls.uia_controls.MenuItemWrapper auto.controls.hwndwrapper.HwndWrapper
method), 115 method), 85
select() (pywinauto.controls.uia_controls.TabControlWrapper
send_keystrokes() (pywin-
method), 116 auto.controls.hwndwrapper.HwndWrapper
select() (pywinauto.controls.uiawrapper.UIAWrapper method), 85
method), 111 send_message() (pywin-
Select() (pywinauto.controls.win32_controls.ComboBoxWrapper auto.controls.hwndwrapper.HwndWrapper
method), 105 method), 86
select() (pywinauto.controls.win32_controls.ComboBoxWrapper
send_message_timeout() (pywin-
method), 105 auto.controls.hwndwrapper.HwndWrapper
Select() (pywinauto.controls.win32_controls.EditWrapper method), 86
method), 106 set_application_data() (pywin-
select() (pywinauto.controls.win32_controls.EditWrapper auto.controls.hwndwrapper.HwndWrapper
method), 106 method), 86
Select() (pywinauto.controls.win32_controls.ListBoxWrapper
set_base() (pywinauto.controls.common_controls.UpDownWrapper
method), 107 method), 103
select() (pywinauto.controls.win32_controls.ListBoxWrapper
set_border() (pywinauto.controls.common_controls.CalendarWrapper
method), 107 method), 93
selected_index() (pywin- set_cache_strategy() (pywin-
auto.controls.uia_controls.ComboBoxWrapper auto.element_info.ElementInfo method),
method), 112 126
selected_index() (pywin- set_cache_strategy() (pywin-
auto.controls.win32_controls.ComboBoxWrapper auto.uia_element_info.UIAElementInfo
method), 105 method), 128
selected_indices() (pywin- set_cache_strategy() (pywin-
auto.controls.win32_controls.ListBoxWrapper auto.win32_element_info.HwndElementInfo
method), 107 method), 127
selected_item_index() (pywin- set_check_indeterminate() (pywin-
auto.controls.uiawrapper.UIAWrapper auto.controls.win32_controls.ButtonWrapper
method), 111 method), 104
selected_text() (pywinauto.controls.uia_controls.ComboBoxWrapper
set_color() (pywinauto.controls.common_controls.CalendarWrapper
method), 112 method), 93
selected_text() (pywinauto.controls.win32_controls.ComboBoxWrapper
set_current_date() (pywin-
method), 105 auto.controls.common_controls.CalendarWrapper
SelectedIndex() (pywin- method), 93
auto.controls.win32_controls.ComboBoxWrapperset_day_states() (pywin-
method), 105 auto.controls.common_controls.CalendarWrapper
SelectedIndices() (pywin- method), 93
auto.controls.win32_controls.ListBoxWrapper set_edit_text() (pywinauto.controls.uia_controls.EditWrapper
method), 107 method), 113
SelectedText() (pywinauto.controls.win32_controls.ComboBoxWrapper
set_edit_text() (pywinauto.controls.win32_controls.EditWrapper
method), 105 method), 106

154 Index
pywinauto Documentation, Release 0.6.8

set_first_weekday() (pywin- method), 115


auto.controls.common_controls.CalendarWrapperset_view() (pywinauto.controls.common_controls.CalendarWrapper
method), 93 method), 93
set_focus() (pywinauto.base_wrapper.BaseWrapper set_window_text() (pywin-
method), 79 auto.controls.hwndwrapper.HwndWrapper
set_focus() (pywinauto.controls.hwndwrapper.HwndWrapper method), 86
method), 86 set_window_text() (pywin-
set_focus() (pywinauto.controls.uiawrapper.UIAWrapper auto.controls.uia_controls.EditWrapper
method), 111 method), 113
set_id() (pywinauto.controls.common_controls.CalendarWrapper
set_window_text() (pywin-
method), 93 auto.controls.win32_controls.EditWrapper
set_item_focus() (pywin- method), 106
auto.controls.win32_controls.ListBoxWrapper SetBase() (pywinauto.controls.common_controls.UpDownWrapper
method), 107 method), 103
set_keyboard_focus() (pywin- SetCheckIndeterminate() (pywin-
auto.controls.hwndwrapper.HwndWrapper auto.controls.win32_controls.ButtonWrapper
method), 86 method), 104
set_level() (in module pywinauto.actionlogger), 132 SetEditText() (pywinauto.controls.win32_controls.EditWrapper
set_line_size() (pywinauto.controls.common_controls.TrackbarWrapper method), 106
method), 101 SetItemFocus() (pywin-
set_month_delta() (pywin- auto.controls.win32_controls.ListBoxWrapper
auto.controls.common_controls.CalendarWrapper method), 107
method), 93 SetPosition() (pywinauto.controls.common_controls.PagerWrapper
set_page_size() (pywin- method), 96
auto.controls.common_controls.TrackbarWrapperSetPosition() (pywinauto.controls.common_controls.ProgressWrapper
method), 101 method), 97
set_position() (pywinauto.controls.common_controls.PagerWrapper
SetReferenceControls() (in module pywin-
method), 96 auto.controlproperties), 129
set_position() (pywinauto.controls.common_controls.ProgressWrapper
SetText() (pywinauto.controls.win32_controls.EditWrapper
method), 97 method), 106
set_position() (pywinauto.controls.common_controls.TrackbarWrapper
SetTime() (pywinauto.controls.common_controls.DateTimePickerWrapper
method), 101 method), 93
set_range_max() (pywin- SetValue() (pywinauto.controls.common_controls.UpDownWrapper
auto.controls.common_controls.TrackbarWrapper method), 103
method), 101 show_in_taskbar() (pywin-
set_range_min() (pywin- auto.controls.hwndwrapper.DialogWrapper
auto.controls.common_controls.TrackbarWrapper method), 81
method), 101 ShowInTaskbar() (pywin-
set_sel() (pywinauto.controls.common_controls.TrackbarWrapper auto.controls.hwndwrapper.DialogWrapper
method), 101 method), 81
set_text() (pywinauto.controls.uia_controls.EditWrapper SliderWrapper (class in pywinauto.controls.uia_controls),
method), 113 115
set_text() (pywinauto.controls.win32_controls.EditWrapper Slow() (pywinauto.timings.TimeConfig method), 73
method), 106 slow() (pywinauto.timings.TimeConfig method), 73
set_time() (pywinauto.controls.common_controls.DateTimePickerWrapper
small_change() (pywin-
method), 93 auto.controls.uia_controls.SliderWrapper
set_today() (pywinauto.controls.common_controls.CalendarWrapper method), 115
method), 93 start() (pywinauto.application.Application method), 66
set_transparency() (pywin- start_dragging() (pywin-
auto.controls.hwndwrapper.HwndWrapper auto.controls.common_controls._treeview_element
method), 86 method), 90
set_value() (pywinauto.controls.common_controls.UpDownWrapper
state() (pywinauto.controls.common_controls._listview_item
method), 103 method), 92
set_value() (pywinauto.controls.uia_controls.SliderWrapper state() (pywinauto.controls.common_controls._toolbar_button

Index 155
pywinauto Documentation, Release 0.6.8

method), 89 TextBlock() (pywinauto.controls.win32_controls.EditWrapper


state() (pywinauto.controls.common_controls._treeview_element method), 106
method), 90 texts() (pywinauto.base_wrapper.BaseWrapper method),
state() (pywinauto.controls.menuwrapper.MenuItem 79
method), 88 texts() (pywinauto.controls.common_controls.HeaderWrapper
StaticWrapper (class in pywinauto.controls.uia_controls), method), 94
115 texts() (pywinauto.controls.common_controls.ListViewWrapper
StaticWrapper (class in pywin- method), 96
auto.controls.win32_controls), 108 texts() (pywinauto.controls.common_controls.ReBarWrapper
StatusBarWrapper (class in pywin- method), 97
auto.controls.common_controls), 97 texts() (pywinauto.controls.common_controls.StatusBarWrapper
step_it() (pywinauto.controls.common_controls.ProgressWrapper method), 98
method), 97 texts() (pywinauto.controls.common_controls.TabControlWrapper
StepIt() (pywinauto.controls.common_controls.ProgressWrapper method), 99
method), 97 texts() (pywinauto.controls.common_controls.ToolbarWrapper
stop() (pywinauto.win32_hooks.Hook method), 76 method), 100
style() (in module pywinauto.handleprops), 131 texts() (pywinauto.controls.common_controls.ToolTipsWrapper
style() (pywinauto.controls.common_controls._toolbar_button method), 99
method), 89 texts() (pywinauto.controls.common_controls.TreeViewWrapper
style() (pywinauto.controls.hwndwrapper.HwndWrapper method), 102
method), 86 texts() (pywinauto.controls.uia_controls.ComboBoxWrapper
sub_elements() (pywin- method), 112
auto.controls.common_controls._treeview_elementtexts() (pywinauto.controls.uia_controls.EditWrapper
method), 90 method), 113
sub_elements() (pywin- texts() (pywinauto.controls.uia_controls.ListItemWrapper
auto.controls.uia_controls.TreeItemWrapper method), 113
method), 117 texts() (pywinauto.controls.uia_controls.ListViewWrapper
sub_menu() (pywinauto.controls.menuwrapper.MenuItem method), 114
method), 88 texts() (pywinauto.controls.uia_controls.TabControlWrapper
method), 116
T texts() (pywinauto.controls.uia_controls.ToolbarWrapper
tab_count() (pywinauto.controls.common_controls.TabControlWrapper method), 116
method), 99 texts() (pywinauto.controls.win32_controls.ComboBoxWrapper
tab_count() (pywinauto.controls.uia_controls.TabControlWrapper method), 105
method), 116 texts() (pywinauto.controls.win32_controls.EditWrapper
TabControlWrapper (class in pywin- method), 106
auto.controls.common_controls), 98 texts() (pywinauto.controls.win32_controls.ListBoxWrapper
TabControlWrapper (class in pywin- method), 107
auto.controls.uia_controls), 116 TimeConfig (class in pywinauto.timings), 73
TimeoutError, 73
TabCount() (pywinauto.controls.common_controls.TabControlWrapper
method), 98 timestamp() (in module pywinauto.timings), 74
text() (in module pywinauto.handleprops), 131 tip_texts() (pywinauto.controls.common_controls.ToolbarWrapper
text() (pywinauto.controls.common_controls._listview_item method), 100
method), 92 TipTexts() (pywinauto.controls.common_controls.ToolbarWrapper
text() (pywinauto.controls.common_controls._toolbar_button method), 100
method), 89 toggle() (pywinauto.controls.uia_controls.ButtonWrapper
text() (pywinauto.controls.common_controls._treeview_element method), 112
method), 90 tool_count() (pywinauto.controls.common_controls.ToolTipsWrapper
text() (pywinauto.controls.menuwrapper.MenuItem method), 99
method), 88 ToolbarWrapper (class in pywin-
text_block() (pywinauto.controls.uia_controls.EditWrapper auto.controls.common_controls), 99
method), 113 ToolbarWrapper (class in pywin-
text_block() (pywinauto.controls.win32_controls.EditWrapper auto.controls.uia_controls), 116
method), 106 ToolCount() (pywinauto.controls.common_controls.ToolTipsWrapper

156 Index
pywinauto Documentation, Release 0.6.8

method), 99 uncheck_by_click() (pywin-


ToolTip (class in pywinauto.controls.common_controls), auto.controls.win32_controls.ButtonWrapper
99 method), 104
ToolTipsWrapper (class in pywin- uncheck_by_click_input() (pywin-
auto.controls.common_controls), 99 auto.controls.win32_controls.ButtonWrapper
TooltipWrapper (class in pywin- method), 104
auto.controls.uia_controls), 116 UncheckByClick() (pywin-
top_from_point() (pywin- auto.controls.win32_controls.ButtonWrapper
auto.base_wrapper.BaseWrapper method), method), 104
79 UncheckByClickInput() (pywin-
top_from_point() (pywin- auto.controls.win32_controls.ButtonWrapper
auto.uia_element_info.UIAElementInfo class method), 104
method), 128 unhook_keyboard() (pywinauto.win32_hooks.Hook
top_from_point() (pywin- method), 76
auto.win32_element_info.HwndElementInfo unhook_mouse() (pywinauto.win32_hooks.Hook
class method), 127 method), 76
top_level_parent() (pywin- UniqueDict (class in pywinauto.findbestmatch), 69
auto.base_wrapper.BaseWrapper method), UpDownWrapper (class in pywin-
79 auto.controls.common_controls), 103
top_window() (pywinauto.application.Application user_data() (pywinauto.controls.hwndwrapper.HwndWrapper
method), 66 method), 86
TrackbarWrapper (class in pywin- userdata() (in module pywinauto.handleprops), 131
auto.controls.common_controls), 100
TranslationTest() (in module pywinauto.tests.translation), V
124 value() (pywinauto.controls.uia_controls.SliderWrapper
tree_root() (pywinauto.controls.common_controls.TreeViewWrapper method), 115
method), 102 verify_actionable() (pywin-
TreeItemWrapper (class in pywin- auto.base_wrapper.BaseWrapper method),
auto.controls.uia_controls), 116 79
TreeViewWrapper (class in pywin- verify_enabled() (pywinauto.base_wrapper.BaseWrapper
auto.controls.common_controls), 101 method), 80
TreeViewWrapper (class in pywin- verify_visible() (pywinauto.base_wrapper.BaseWrapper
auto.controls.uia_controls), 117 method), 80
TruncationTest() (in module pywinauto.tests.truncation), visible (pywinauto.element_info.ElementInfo attribute),
124 126
type_keys() (pywinauto.base_wrapper.BaseWrapper visible (pywinauto.uia_element_info.UIAElementInfo at-
method), 79 tribute), 128
visible (pywinauto.win32_element_info.HwndElementInfo
U attribute), 127
UIAElementInfo (class in pywinauto.uia_element_info),
127 W
UiaMeta (class in pywinauto.controls.uiawrapper), 111 wait() (pywinauto.application.WindowSpecification
UIAWrapper (class in pywinauto.controls.uiawrapper), method), 68
108 wait_cpu_usage_lower() (pywin-
uncheck() (pywinauto.controls.common_controls._listview_item auto.application.Application method), 66
method), 92 WAIT_CRITERIA_MAP (pywin-
UnCheck() (pywinauto.controls.common_controls.ListViewWrapper auto.application.WindowSpecification at-
method), 95 tribute), 67
uncheck() (pywinauto.controls.common_controls.ListViewWrapper
wait_for_idle() (pywinauto.base_wrapper.BaseWrapper
method), 96 method), 80
UnCheck() (pywinauto.controls.win32_controls.ButtonWrapper wait_for_idle() (pywin-
method), 104 auto.controls.hwndwrapper.HwndWrapper
uncheck() (pywinauto.controls.win32_controls.ButtonWrapper method), 86
method), 104

Index 157
pywinauto Documentation, Release 0.6.8

wait_for_process_exit() (pywin- windowclasses (pywin-


auto.application.Application method), 66 auto.controls.common_controls.ReBarWrapper
wait_not() (pywinauto.application.WindowSpecification attribute), 97
method), 68 windowclasses (pywin-
wait_until() (in module pywinauto.timings), 74 auto.controls.common_controls.StatusBarWrapper
wait_until_passes() (in module pywinauto.timings), 74 attribute), 98
was_maximized() (pywin- windowclasses (pywin-
auto.base_wrapper.BaseWrapper method), auto.controls.common_controls.TabControlWrapper
80 attribute), 99
wheel_click() (in module pywinauto.mouse), 63 windowclasses (pywin-
wheel_mouse_input() (pywin- auto.controls.common_controls.ToolbarWrapper
auto.base_wrapper.BaseWrapper method), attribute), 100
80 windowclasses (pywin-
window() (pywinauto.application.Application method), auto.controls.common_controls.ToolTipsWrapper
66 attribute), 99
window() (pywinauto.application.WindowSpecification windowclasses (pywin-
method), 69 auto.controls.common_controls.TrackbarWrapper
window_text() (pywinauto.base_wrapper.BaseWrapper attribute), 101
method), 80 windowclasses (pywin-
window_text() (pywinauto.controlproperties.ControlProps auto.controls.common_controls.TreeViewWrapper
method), 129 attribute), 103
WindowAmbiguousError, 70 windowclasses (pywin-
windowclasses (pywinauto.base_wrapper.BaseWrapper auto.controls.common_controls.UpDownWrapper
attribute), 80 attribute), 103
windowclasses (pywin- windowclasses (pywin-
auto.controls.common_controls.AnimationWrapper auto.controls.win32_controls.ButtonWrapper
attribute), 92 attribute), 105
windowclasses (pywin- windowclasses (pywin-
auto.controls.common_controls.CalendarWrapper auto.controls.win32_controls.ComboBoxWrapper
attribute), 93 attribute), 105
windowclasses (pywin- windowclasses (pywin-
auto.controls.common_controls.ComboBoxExWrapper auto.controls.win32_controls.EditWrapper
attribute), 93 attribute), 106
windowclasses (pywin- windowclasses (pywin-
auto.controls.common_controls.DateTimePickerWrapper auto.controls.win32_controls.ListBoxWrapper
attribute), 94 attribute), 107
windowclasses (pywin- windowclasses (pywin-
auto.controls.common_controls.HeaderWrapper auto.controls.win32_controls.PopupMenuWrapper
attribute), 94 attribute), 107
windowclasses (pywin- windowclasses (pywin-
auto.controls.common_controls.HotkeyWrapper auto.controls.win32_controls.StaticWrapper
attribute), 94 attribute), 108
windowclasses (pywin- WindowNotFoundError, 70
auto.controls.common_controls.IPAddressWrapper windows() (pywinauto.application.Application method),
attribute), 94 67
windowclasses (pywin- WindowSpecification (class in pywinauto.application), 67
auto.controls.common_controls.ListViewWrapperWindowText() (pywinauto.controlproperties.ControlProps
attribute), 96 method), 129
windowclasses (pywin- wm_get_ctrl_name (pywin-
auto.controls.common_controls.PagerWrapper auto.win32_element_info.HwndElementInfo
attribute), 96 attribute), 127
windowclasses (pywin- wm_get_ctrl_type (pywin-
auto.controls.common_controls.ProgressWrapper auto.win32_element_info.HwndElementInfo
attribute), 97 attribute), 127

158 Index
pywinauto Documentation, Release 0.6.8

wrapper_class (pywinauto.backend.BackendsRegistry at- method), 133


tribute), 125 write_to_xml() (pywin-
wrapper_class() (in module pywinauto.backend), 125 auto.controls.hwndwrapper.DialogWrapper
wrapper_object() (pywin- method), 81
auto.application.WindowSpecification WriteAppData() (pywinauto.application.Application
method), 69 method), 65
writable_props (pywinauto.base_wrapper.BaseWrapper WriteDialogToFile() (in module pywinauto.xml_helpers),
attribute), 80 131
writable_props (pywin- WriteToXML() (pywin-
auto.controls.common_controls.ListViewWrapper auto.controls.hwndwrapper.DialogWrapper
attribute), 96 method), 81
writable_props (pywin-
auto.controls.common_controls.ReBarWrapper X
attribute), 97 XMLParsingError, 131
writable_props (pywin-
auto.controls.common_controls.StatusBarWrapper
attribute), 98
writable_props (pywin-
auto.controls.common_controls.TabControlWrapper
attribute), 99
writable_props (pywin-
auto.controls.common_controls.ToolbarWrapper
attribute), 100
writable_props (pywin-
auto.controls.common_controls.TreeViewWrapper
attribute), 103
writable_props (pywin-
auto.controls.hwndwrapper.HwndWrapper
attribute), 86
writable_props (pywin-
auto.controls.uia_controls.EditWrapper at-
tribute), 113
writable_props (pywin-
auto.controls.uia_controls.ListViewWrapper
attribute), 115
writable_props (pywin-
auto.controls.uia_controls.ToolbarWrapper
attribute), 116
writable_props (pywin-
auto.controls.uia_controls.TreeViewWrapper
attribute), 117
writable_props (pywin-
auto.controls.uiawrapper.UIAWrapper at-
tribute), 111
writable_props (pywin-
auto.controls.win32_controls.ComboBoxWrapper
attribute), 105
writable_props (pywin-
auto.controls.win32_controls.EditWrapper
attribute), 106
writable_props (pywin-
auto.controls.win32_controls.ListBoxWrapper
attribute), 107
Write() (pywinauto.remote_memory_block.RemoteMemoryBlock

Index 159

You might also like