Python Forum
Automating Windows GUI applications - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Automating Windows GUI applications (/thread-24253.html)



Automating Windows GUI applications - metro17 - Feb-06-2020

from pywinauto import application
app = application.Application()
app.start("Notepad.exe")

The above code launches a notepad.

But when I try to run this this .It throws and error and fails to launch the executable

from pywinauto import application
app = application.Application()
app.start("C:\Program Files\Microsoft Assessment and Planning Toolkit\bin\MapToolkit.exe")

Traceback (most recent call last):
File "C:\Users\km041320\AppData\Local\Continuum\anaconda3\lib\site-packages\pywinauto\application.py", line 1047, in start
start_info) # STARTUPINFO structure.
pywintypes.error: (2, 'CreateProcess', 'The system cannot find the file specified.')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\km041320\AppData\Local\Continuum\anaconda3\lib\site-packages\pywinauto\application.py", line 1052, in start
raise AppStartError(message)
pywinauto.application.AppStartError: Could not create the process "C:\Program Files\Microsoft Assessment and Planning Toolkiin\MapToolkit.exe"
Error returned by CreateProcess: (2, 'CreateProcess', 'The system cannot find the file specified.')


RE: Automating Windows GUI applications - buran - Feb-06-2020

Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.

You were warned on multiple occasions. I will lock this thread now and you are free to repost, using proper BBcode tags, as per forum rules


Automating Windows GUI application - metro17 - Feb-06-2020

from pywinauto import application
app = application.Application()
app.start("Notepad.exe")
The above code launches a notepad.
But when I try to run this.It throws and error and fails to launch the executable

from pywinauto import application
app = application.Application()
app.start("C:\Program Files\Microsoft Assessment and Planning Toolkit\bin\MapToolkit.exe")
Error:
Traceback (most recent call last): File "C:\Users\ABCD\AppData\Local\Continuum\anaconda3\lib\site-packages\pywinauto\application.py", line 1047, in start start_info) # STARTUPINFO structure. pywintypes.error: (2, 'CreateProcess', 'The system cannot find the file specified.') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\ABCD\AppData\Local\Continuum\anaconda3\lib\site-packages\pywinauto\application.py", line 1052, in start raise AppStartError(message) pywinauto.application.AppStartError: Could not create the process "C:\Program Files\Microsoft Assessment and Planning Toolkiin\MapToolkit.exe" Error returned by CreateProcess: (2, 'CreateProcess', 'The system cannot find the file specified.')



RE: Automating Windows GUI application - buran - Feb-06-2020

Whit windows paths, don't use backslash. Use forward slash or raw-strings, e.g.
app.start("C:/Program Files/Microsoft Assessment and Planning Toolkit/bin/MapToolkit.exe")
or
app.start(r"C:\Program Files\Microsoft Assessment and Planning Toolkit\bin\MapToolkit.exe")
back-slash in combination with certain chars are escape sequences and have a different meaning


RE: Automating Windows GUI applications - metro17 - Feb-10-2020

>>> app.start(r"C:\Program Files\Microsoft Assessment and Planning Toolkit\bin\MapToolkit.exe")
Traceback (most recent call last):
  File "C:\Users\ABCD\AppData\Local\Continuum\anaconda3\lib\site-packages\pywinauto\application.py", line 1047, in start
    start_info)                         # STARTUPINFO structure.
pywintypes.error: (740, 'CreateProcess', 'The requested operation requires elevation.')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\ABCD\AppData\Local\Continuum\anaconda3\lib\site-packages\pywinauto\application.py", line 1052, in start
    raise AppStartError(message)
pywinauto.application.AppStartError: Could not create the process "C:\Program Files\Microsoft Assessment and Planning Toolkit\bin\MapToolkit.exe"
Error returned by CreateProcess: (740, 'CreateProcess', 'The requested operation requires elevation.')
>>>

>>> app.start("C:/Program Files/Microsoft Assessment and Planning Toolkit/bin/MapToolkit.exe")
Traceback (most recent call last):
  File "C:\Users\km041320\AppData\Local\Continuum\anaconda3\lib\site-packages\pywinauto\application.py", line 1047, in start
    start_info)                         # STARTUPINFO structure.
pywintypes.error: (740, 'CreateProcess', 'The requested operation requires elevation.')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\km041320\AppData\Local\Continuum\anaconda3\lib\site-packages\pywinauto\application.py", line 1052, in start
    raise AppStartError(message)
pywinauto.application.AppStartError: Could not create the process "C:/Program Files/Microsoft Assessment and Planning Toolkit/bin/MapToolkit.exe"
Error returned by CreateProcess: (740, 'CreateProcess', 'The requested operation requires elevation.')

worked after opening cmd as admin
Thanks