I'm trying to automate a series of GUI controls in a ClickOnce application, however I'm having problems to launch the application through my automation code. What I'd like to do is launch the application with CreateProcess()
, so I can have a window handle to execute my controls.
This is my current code (I omitted the path to the app):
import win32process
import win32con
path_to_app = "path_to_application\\application.appref-ms"
startupinfo = win32process.STARTUPINFO()
(hprocess, hthread, dwprocessid, dwthreadid) = win32process.CreateProcess(path_to_app, None, None, None, 0, win32con.NORMAL_PRIORITY_CLASS, None, None, startupinfo)
# Execute controls here
And this is the error I'm getting:
pywintypes.error: (193, 'CreateProcess', '%1 is not a valid Win32 application.')
If I try to directly open the .exe
that will eventually run, it fails with a message that I should run through the shortcut (in this case the .appref-ms
).
How is it possible to start the application and get its window handle?