Python Forum

Full Version: pywinauto problems
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Apologies if this is the wrong location for the post, i wasn't sure where it fits...anyways:

I already had python 3.6 installed on windows 10 and have just also installed pywinauto
to do this i just ran >pip install pywinauto  via the command line

I have been experimenting with very basic code straight into cmd and via the python shell which works fine.
However if i create a py file via IDLE i just get an import error for 'application' see below:
 
Error:
Traceback (most recent call last):   File "C:\Users\<myuser>\Desktop\pywinauto.py", line 1, in <module>     from pywinauto import application   File "C:\Users\<myuser>\Desktop\pywinauto.py", line 1, in <module>     from pywinauto import application ImportError: cannot import name 'application'
i'm sure this is something to do with the env variables or the relevant path etc ..but i'm not proficient enough to solve the problem.

the code i've started with is:
from pywinauto import application

import time

def main():
   app = application.Application()
   app.start("Notepad.exe")
   time.sleep(3)
   app.notepad.edit.TypeKeys("Hello World")
   time.sleep(2)
   app.Notepad.menuSelect("File ->SaveAs")
   app.SveAs.edit.SetText("pywinautodemo.txt")
   app.SaveAs.Save.Click()

main()
Any help greatly appreciated!

ta
   VNC
(Apr-13-2017, 10:32 AM)vnc Wrote: [ -> ]Apologies if this is the wrong location for the post, i wasn't sure where it fits...anyways: I already had python 3.6 installed on windows 10 and have just also installed pywinauto to do this i just ran >pip install pywinauto  via the command line I have been experimenting with very basic code straight into cmd and via the python shell which works fine. However if i create a py file via IDLE i just get an import error for 'application' see below:    Traceback (most recent call last):   File "C:\Users\<myuser>\Desktop\pywinauto.py", line 1, in <module>     from pywinauto import application   File "C:\Users\<myuser>\Desktop\pywinauto.py", line 1, in <module>     from pywinauto import application ImportError: cannot import name 'application' i'm sure this is something to do with the env variables or the relevant path etc ..but i'm not proficient enough to solve the problem. the code i've started with is: from pywinauto import application import time def main():   app = application.Application()   app.start("Notepad.exe")   time.sleep(3)   app.notepad.edit.TypeKeys("Hello World")   time.sleep(2)   app.Notepad.menuSelect("File ->SaveAs")   app.SveAs.edit.SetText("pywinautodemo.txt")   app.SaveAs.Save.Click() main() Any help greatly appreciated! ta    VNC
There is most likely something wrong with the "application" name or whatever you call it. Check on the internet, because it says it cannot import it.
from pywinauto import Application # upper 'A'

app = Application()
Ref: https://github.com/pywinauto/pywinauto
(Apr-13-2017, 11:03 AM)wavic Wrote: [ -> ]
from pywinauto import Application # upper 'A'

app = Application()
Ref: https://github.com/pywinauto/pywinauto

Thanks tried that ..makes no difference to the error message except for an upper case A