I am completely lost in using "win32com.client" to open an exe program and run it. I used the code appended at the end, but I get the following error:
File "C:\Program Files\Anaconda3\lib\site-packages\win32com\client_init_.py", line 113, in DispatchEx dispatch = pythoncom.CoCreateInstanceEx(clsid, None, clsctx, serverInfo, (pythoncom.IID_IDispatch,))[0]
com_error: (-2147221005, 'Invalid class string', None, None)
I am quite lost, and hope someone could assist. Thank you!
1st: do I state the exe prog complete file path here?
Complete Code
File "C:\Program Files\Anaconda3\lib\site-packages\win32com\client_init_.py", line 113, in DispatchEx dispatch = pythoncom.CoCreateInstanceEx(clsid, None, clsctx, serverInfo, (pythoncom.IID_IDispatch,))[0]
com_error: (-2147221005, 'Invalid class string', None, None)
I am quite lost, and hope someone could assist. Thank you!
1st: do I state the exe prog complete file path here?
shell = w3c.DispatchEx('C:/Program Files/FAME.exe')2nd: is it correct to use FAME to refer to the application here?
shell.Run('FAME')3rd: For AppActivate, is the argument the title bar of my application?
shell.AppActivate('FAME')
Complete Code
import win32com.client as w3c
shell = w3c.DispatchEx('C:/Program Files/FAME.exe')
shell.Run('FAME')
time.sleep(5)
shell.AppActivate('FAME')
shell.SendKeys("input +""C:\programs\FAMESCRIPT.txt""+{ENTER}", 1)