Pywinauto GUI Automation

0.6.9 · active · verified Sat Apr 11

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.

Warnings

Install

Imports

Quickstart

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?'

view raw JSON →