Search code examples
pythonpywinauto

Python - pywinauto - one input causes multiple actions


I'm doing some program installer automation using Python and pywinauto. However, I have stumbled onto a problem that I cannot solve. For some reason on this page of this particular installer when I send the window an input using pywinauto it seems to also send inputs to all the buttons then it finally clicks the one I commanded. Below is the code that causes the problem. It seems like this problem is induced when ever I look at app.Dialog.ComboBox because I get the same weird error when I call methods like Rectangle.

app = Application(backend="uia").connect(title_re = 'My program name', timeout=1000)
app.Dialog.ComboBox2.click_input()

Solution

  • I was able to find a solution to my issue, though I had to use another module. I could not figure this out using pywinauto. I suspect it is a deep issue in how the module is written and would require a lot of time to fix. I instead used the uiautomation module. Below is my code to select one item from the software list.

    import uiautomation
    
    app = uiautomation.WindowControl(searchDepth=1, Name='WindowName')
    app.Control(searchDepth=6, AutomationId = 'Products.BtnProductSet0.Cbx').Click()