{"id":3786,"library":"pywinauto","title":"Pywinauto GUI Automation","description":"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.","status":"active","version":"0.6.9","language":"en","source_language":"en","source_url":"https://github.com/pywinauto/pywinauto","tags":["windows","gui automation","desktop","testing","robotics"],"install":[{"cmd":"pip install pywinauto","lang":"bash","label":"Install latest stable version"}],"dependencies":[{"reason":"Provides access to the Windows API. pywinauto switched from pypiwin32 to pywin32 (official) in v0.6.5.","package":"pywin32","optional":false},{"reason":"Required for the 'uia' backend to interact with UI Automation Core.","package":"comtypes","optional":true}],"imports":[{"symbol":"Application","correct":"from pywinauto import Application"},{"symbol":"Desktop","correct":"from pywinauto.Desktop import Desktop"}],"quickstart":{"code":"from pywinauto import Application\n\n# Start a new application\napp = Application().start(\"notepad.exe\")\n\n# Connect to an existing application (e.g., if Notepad is already open)\n# app = Application().connect(title_re=\"Untitled - Notepad\")\n\n# Interact with the main window\nnotepad_window = app.UntitledNotepad\n\n# Select a menu item\nnotepad_window.menu_select(\"Help->About Notepad\")\n\n# Click a button on the About dialog\napp.AboutNotepad.OK.click()\n\n# Type text into the edit control\nnotepad_window.Edit.type_keys(\"Hello pywinauto!\\nThis is an automated message.\", with_spaces=True, with_newlines=True)\n\n# Close the application (uncomment to run)\n# notepad_window.menu_select(\"File->Exit\")\n# app.Notepad.dont_save.click() # Adjust based on actual dialog for 'Do you want to save?'\n","lang":"python","description":"This quickstart demonstrates how to launch Notepad, interact with its menus, close a dialog, and type text into its main edit control using `pywinauto`."},"warnings":[{"fix":"Ensure your project is running on Python 3.x if you plan to upgrade pywinauto beyond version 0.6.9.","message":"Pywinauto 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.","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Specify the backend explicitly when initializing `Application`: `app = Application(backend='uia').start('your_app.exe')` or `Desktop(backend='uia').windows()`.","message":"Pywinauto 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Run your Python script with the same or higher administrative privileges as the target application.","message":"If 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).","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Finding controls can be challenging. 'Magic lookup' (e.g., `app.Dialog.Button`) can be fragile. Controls may have similar names or dynamic IDs.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If `type_keys` fails to input text, try setting `vk_packet=False`: `control.type_keys('text', vk_packet=False)`.","message":"For some applications, the `type_keys` method (used for keyboard input) may not work correctly if they don't handle `VK_PACKET` properly.","severity":"gotcha","affected_versions":">=0.6.8"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}