简体   繁体   English

使用Python打开第三方应用程序

[英]Open 3rd party Application with Python

I am on Windows XP and have a 3rd party application that I want to be able to open using a Python script. 我在Windows XP上,并且拥有一个我希望能够使用Python脚本打开的第三方应用程序。 How do I go about doing it? 我该怎么做呢?

from win32com.client import Dispatch
mySuite = Dispatch("TestSuite.Application")

throws an error 引发错误

File "C:\Python26\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript
exec codeObject in __main__.__dict__
File "C:\Documents and Settings\Script1.py", line 2, in <module>
mySuite = Dispatch("TestSuite.Application")
File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
com_error: (-2147221005, 'Invalid class string', None, None)

Any pointers? 有指针吗? Thanks. 谢谢。

Looks like the TestSuite.Application COM class has not been registered -- try opening it in, say, VBScript, to verify, and it should also fail. 看起来TestSuite.Application COM类尚未注册-尝试在例如VBScript中打开它进行验证,它也应该失败。 In which case maybe you can fix it with regsvr32.exe or similar tools. 在这种情况下,您可以使用regsvr32.exe或类似工具修复它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM