cannot import name 'Desktop' from 'pywinauto'

854 Views Asked by At

I'm trying to use pywinauto to control the calculator in win 10.

I installed pywinauto-0.6.8 and

from pywinauto import Desktop, Application

app = Application(backend="uia").start('calc.exe')

dlg = Desktop(backend="uia").Calculator
dlg.type_keys('2*3=')
dlg.print_control_identifiers()

dlg.minimize()
Desktop(backend="uia").window(title='Calculator', visible_only=False).restore()

But the received error:

ImportError: cannot import name 'Desktop' from 'pywinauto' (C:\Users\MJ\Anaconda3\lib\site-packages\pywinauto__init__.py)

1

There are 1 best solutions below

0
On

The same code works for me.

Please verify the version of pywinauto you have installed, by

pip list (for MAC use: pip3 list)

Since, Desktop was introduced in one of 0.6.x releases.

Or, try reinstalling it with

pip install --upgrade pywinauto