Python Forum
Automating Windows GUI applications
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Automating Windows GUI applications
#1
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.')

User has been warned for this post. Reason: Not following directions after repeatedly informed
Reply
#2
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
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.')
Reply
#4
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
>>> 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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Is there a python program for automating this invoicing workflow? PG_Archipelago 3 1,032 Feb-02-2023, 11:01 PM
Last Post: Larz60+
  Help with Creating a Script for Automating Reports SunWers 1 1,884 Dec-29-2020, 10:21 PM
Last Post: jjc385
  Automating to run python script 100 times by changing parameters pmt 1 2,563 Dec-29-2020, 10:31 AM
Last Post: andydoc
  Opening and closing Mac applications and files Nickd12 5 5,575 Sep-05-2020, 04:39 AM
Last Post: perfringo
  Internationalization of applications ? JohnnyCoffee 1 1,714 Apr-17-2020, 09:39 PM
Last Post: Larz60+
  Handling Thick client applications using Python PraveenSubramaniyan 1 3,177 Jul-22-2019, 01:08 PM
Last Post: DeaD_EyE
  Automating Excel sheets with Python wendysling 1 2,535 Mar-15-2019, 01:39 PM
Last Post: Larz60+
  Automating unittest ichabod801 3 2,711 Oct-28-2018, 09:32 PM
Last Post: Gribouillis
  Glob and automating help Thunberd 0 2,351 Jun-13-2018, 04:42 PM
Last Post: Thunberd
  automating cli configs using python yumapath 1 2,483 Aug-30-2017, 01:23 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020