开发者

error using pywinauto

开发者 https://www.devze.com 2023-02-19 22:45 出处:网络
I am new to python and have just installed pywinauto using easy_install. I am trying to execute a simple code as follow:

I am new to python and have just installed pywinauto using easy_install.

I am trying to execute a simple code as follow:

from pywinauto import application
app = application.Application.start ('notepad.exe')
Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
AttributeError: ty开发者_如何学运维pe object 'Application' has no attribute 'start'

As you see I am getting an error. I tried searching for an answer for this on the web but could not find out why this is happening.

Please help. thanks in advance.

VG


Pywinauto is very confused about the naming convention used (I know - I wrote it!).

There are two choices:

a) create an instance of the Application class first and then call start() on it.

>>> from pywinauto import Application
>>> app = Application()
>>> app.start('notepad.exe')
<pywinauto.application.Application object at 0x022991B0>
>>> app.UntitledNotepad.MenuItem("File -> Exit").Select()

b) call the Application.Start() class method. (starts with uppercase 'S')

>>> app = Application.Start('Notepad')
>>> app.UntitledNotepad.MenuItem("File -> Exit").Select()

Option b) is less typing :)


I do not know pywinauto, butI think you need to create an Application object first and then call start().

app = application.Application(...args...)
app.start(...args...)

(I do not know the exact signature)

0

精彩评论

暂无评论...
验证码 换一张
取 消