win32com (python) 错误 [英] win32com (python) error

查看:63
本文介绍了win32com (python) 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在记事本中为我正在处理的程序自动执行一个操作,但我无法弄清楚我收到的错误消息.

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")

错误

回溯(最近一次调用最后一次):文件",行1、在文件中C:\Python27\lib\site-packages\win32com\client__init__.py",第 95 行,在调度dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) 文件C:\Python27\lib\site-packages\win32com\client\dynamic.py",第 104 行,在 _GetGoodDispatchAndUserName 中return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 84,在_GetGoodDispatchIDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221005, '无效类字符串',无,无)有什么帮助吗?

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?

推荐答案

记事本没有我可以找到的 COM 接口.尝试使用 pywinauto.查看视频以了解其工作原理.

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

这篇关于win32com (python) 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆