Search code examples
pythonpython-3.xpywinauto

Python and PyWinAuto version installation on Windows


I am confused about the following:

  1. My OS is windows 7 64 bit, the application that I am trying to automate using python is a 32 bit application. Now should I install Python 64 bit or 32 bit?

  2. My application is a windows application(not web), so I am trying to install the PyWinAuto. PyWinAuto Installation document in silent mode says "(Python 2.7, 3.1, 3.2, 3.3, 3.4, 3.5)". So this means PyWinAuto is supported only till Python version 3.5?

  3. I then installed Python 3.5.3 (64 bit), installed PyWinAuto using the silent installation command (pip install pywinauto), but when I tried to check if I have installed correctly by starting notepad.exe as explained in the document, the notepad just opened and vanished in a second.

  4. I want to able to perform commands on my application's wpf controls using automation id's which I am able to fetch using the inspect tool. So is this possible using PyWinAuto? I looked into the controls but most are related to the control of objects using coordinates etc. If I have object id, can I use it in all the control functions available?


Solution

  • First I'd recommend to read the Getting Started Guide. It answers many of your questions and explains the core concept.

    1. If you use Win32 API based backend (Application(backend='win32') or just Application()), it's important to install 32-bit Python and use it for 32-bit applications (from 64-bit Python you can crash the app). But for backend='uia' it doesn't matter. Since you're trying to automate WPF app, use backend='uia' as explained in the Getting Started Guide.

    2. Pywinauto is auto-tested on Python 3.6 as well. See AppVeyor build matrix. So no problem to use Py3.6.

    3. Please describe the problem in more details. What the code do you run? From what document did you get it? Maybe it's outdated pywinauto-0.5.4 docs?

    4. Again, the Getting Started Guide explains how to find Inspect.exe (Spy tool from Windows SDK) which can show you all WPF controls. Pywinauto supports almost all complicated WPF lists, grids etc. We have many auto-tests using a WPF sample application. Automation ids can be used as well. Method print_control_identifiers() often shows auto_id='<id>' criterion in a window specification for the controls which have such ids.