Pywinauto

pywinauto is a set of python modules to automate the Microsoft Windows GUI. At its simplest it allows you to send mouse and keyboard actions to windows dialogs and controls, but it also supports more complex actions.

pywinauto 0.6.0 is in the master branch (October, 30, 2016)

  • This big release introduces MS UI Automation (UIA) support.
  • Documentation is built continuously now on ReadTheDocs. See also our improved Getting Started Guide
  • Modules keyboard and mouse can be used out of any window context now. And they work on Linux as well!
  • Multi-backend architecture allows to add new platforms support. Just implement two classes and register your backend!
  • Code style is much closer to PEP8: ClickInput -> click_input. Though backend='win32' is ~80% backward compatible with pywinauto 0.5.4.
  • Initial implementation of the win32_hooks module. Keyboard and mouse event handlers can be registered in the system.

A brand new team logo.

logo This is the new team icon. Thanks, Anna, who created the icon for the team, cat Walter.
PS: Logo for the pywinauto library is still wanted.

Example

It is simple and the resulting scripts are very readable. How simple?

1
2
3
4
5
6
7
8
9
from pywinauto.application import Application
# Run a target application
app = Application().start("notepad.exe")
# Select a menu item
app.UntitledNotepad.menu_select("Help->About Notepad")
# Click on a button
app.AboutNotepad.OK.click()
# Type a text string
app.UntitledNotepad.Edit.type_keys("pywinauto Works!", with_spaces = True)

Setup

  • Just run pip install pywinauto (Py2.7+, Py3.3+)

or

Supported controls

  • Native Windows controls (full support through Win32 API)
  • .NET Windows Forms (full support through MS UI Automation starting with pywinauto 0.6.0)

Demo

Here is a short screencast with Pywinauto in action:

Notepad.exe automation example