Search code examples
pythonui-automationpywinauto

click() does perform a click but ends with an error


I have a button on a dialog box which when it is clicked, pops up a confirm popup window.

Whenever I perform a click on that button using pywinauto, the click does occur in the UI, however the click() function does not return without throwing this error:

COMError: (-2147220991, 'An event was unable to invoke any of the subscribers', (None, None, None, 0, None))

The code to click the button is very simple:

readerDlg = mainDlg.window(title=READER_WINDOW_TITLE)
readerDlg.Skip.click()

Connection snippet:

sw = Application(backend='uia').connect(title=APPLICATION_TITLE)
mainDlg = sw.window(title=MAIN_WINDOW_TITLE)

Solution

  • Switching the backend from uia to win32 fixed my issue:

    sw = Application(backend='win32').connect(title=APPLICATION_TITLE)
    

    It also made the automation much faster (from ~5 sec/op to < 1 sec/op.