win32com (python) error

扶醉桌前 提交于 2020-01-04 11:02:06

问题


i am trying to automate a action in notepad for a program im working on and i cant figure out an error message i am getting.

import os
import win32com

object = win32com.client.Dispatch("Notepad.Application")

error

Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\site-packages\win32com\client__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 104, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 84, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221005, 'Invalid class string', None, None) any help?


回答1:


Notepad has no COM interface that I can Find. Try using pywinauto. Check this video to see how it works.



来源:https://stackoverflow.com/questions/9446844/win32com-python-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!