VGTWIST
VGTWIST

Reputation: 41

error using pywinauto

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: type 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

Upvotes: 2

Views: 3353

Answers (2)

markm
markm

Reputation: 906

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 :)

Upvotes: 4

pajton
pajton

Reputation: 16246

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)

Upvotes: 0

Related Questions