Registry / testing / pywinauto

pywinauto

JSON →
library0.6.9pypypi✓ verified 26d ago

Pywinauto is a set of Python modules for automating the Microsoft Windows GUI. It enables interaction with native Windows applications, supporting both Win32 API (default) and UI Automation (UIA) backends. The current version is 0.6.9, and the library maintains an active release cadence with regular bug fixes and enhancements.

pip install pywinauto
INSTALL
IMPORT
SIG · PYWINAUTO
P
pywinauto
testingpythonv0.6.9
Install
1.9s avg
Import
—
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.6.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 21.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.9s · import 0.000s · 22MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Application
✓ import pywinauto
✗ from pywinauto import Application

This quickstart demonstrates how to launch Notepad, interact with its menus, close a dialog, and type text into its main edit control using `pywinauto`.

from pywinauto import Application # Start a new application app = Application().start("notepad.exe") # Connect to an existing application (e.g., if Notepad is already open) # app = Application().connect(title_re="Untitled - Notepad") # Interact with the main window notepad_window = app.UntitledNotepad # Select a menu item notepad_window.menu_select("Help->About Notepad") # Click a button on the About dialog app.AboutNotepad.OK.click() # Type text into the edit control notepad_window.Edit.type_keys("Hello pywinauto!\nThis is an automated message.", with_spaces=True, with_newlines=True) # Close the application (uncomment to run) # notepad_window.menu_select("File->Exit") # app.Notepad.dont_save.click() # Adjust based on actual dialog for 'Do you want to save?'
Debug
Known issues
breakingPywinauto version 0.6.9 is the last release compatible with Python 2.7. Future versions (e.g., 0.7.0 and beyond) will drop Python 2.7 support, requiring Python 3.
fix
Ensure your project is running on Python 3.x if you plan to upgrade pywinauto beyond version 0.6.9.
affects: >=0.7.0
gotchaPywinauto offers two backends: 'win32' (default) and 'uia'. 'win32' is suitable for older MFC/WinForms apps, while 'uia' (UI Automation) is better for modern apps (WPF, UWP, Electron). Using the wrong backend can lead to controls not being found or interactive.
fix
Specify the backend explicitly when initializing `Application`: `app = Application(backend='uia').start('your_app.exe')` or `Desktop(backend='uia').windows()`.
affects: All versions
gotchaIf the target application runs with elevated (administrator) privileges and your Python script does not, pywinauto may not be able to interact fully or at all due to Windows' UIPI (User Interface Privilege Isolation).
fix
Run your Python script with the same or higher administrative privileges as the target application.
affects: All versions
gotchaFinding controls can be challenging. 'Magic lookup' (e.g., `app.Dialog.Button`) can be fragile. Controls may have similar names or dynamic IDs.
fix
Use `window.print_control_identifiers()` to get a detailed list of available controls and their properties. Use explicit `child_window` arguments like `child_window(title='...', class_name='...', control_type='...')` for robust identification. Since 0.6.5, `auto_id` and `control_type` properties are available for Win32 backend.
affects: All versions
gotchaFor some applications, the `type_keys` method (used for keyboard input) may not work correctly if they don't handle `VK_PACKET` properly.
fix
If `type_keys` fails to input text, try setting `vk_packet=False`: `control.type_keys('text', vk_packet=False)`.
affects: >=0.6.8
Upgrade
Version history
0.6.9latest on PyPI · released Jan 6, 2025
Audit
Dependencies
pywin32requiredProvides access to the Windows API. pywinauto switched from pypiwin32 to pywin32 (official) in v0.6.5.
comtypesoptionalRequired for the 'uia' backend to interact with UI Automation Core.
Agent activity
19 hits · last 30 days
node
16
Resources
pywinauto — pip install pywinauto · libregistry