Search code examples
pythonpython-3.xui-automationpywinauto

Click using automation id in python


Please help !! I managed to install python 3.5.3 (32 bit) and pywinauto. I have started going through the getting started guide for pywinauto. I am using the inspect tool. I have launched the application using the code:

from pywinauto import Application
app = Application().start(r"C:\Program Files (x86)\Trane\TRACE 3D Plus\TRACE™ 3D Plus.exe").

Now as I understood to tell python what the window is we use the:

dlg = app['TRACE™ 3D Plus']

In this screen I have value for automation id and class name using the inspect tool. Please tell me the syntax for clicking on that button using the automation id. For example, a button on my application has the automation id "Airflows" which is seen in the inspect tool. Now how can I click on this using pywinauto?


Solution

  • Automation id can be used with more detailed window specification (see Window Specification chapter in the Getting Started Guide). In your case it should look so:

    dlg = app['TRACE™ 3D Plus']
    dlg.child_window(auto_id='Airflows').invoke() # or .click() that just calls an action
    # or
    dlg.child_window(auto_id='Airflows').click_input() # true click with moving cursor