win32com.client.Dispatch类标签 [英] win32com.client.Dispatch Class Label
问题描述
我正在尝试使用python连接到COM对象。
更具体地说,我正在使用ASCOM标准驱动程序来连接到MaxDome II,并且不知道如何引用该驱动程序。
在此
我希望这会有所帮助!
I am trying to connect to a COM object using python.
More specifically, I am using ASCOM standard drivers to connect to a MaxDome II, and do not know how to reference this driver.
In this link the author uses "Celestron.Telescope" as their parameter for the win32com.client.Dispatch instantiation.
My question is how to find this string. I understand that it is related to the installed drivers, which are installed on the computer, but I don't how to locate the specific string. Is there a way to use win32com.client to list COM objects?
By the way, operating on Windows 7 pro, 64 bit.
Thanks
I do not think it is possible to get the list of COM objects directly from python, however you can run the following code (and indeed run it from inside python) in Powershell:
Get-ChildItem HKLM:\Software\Classes -ErrorAction SilentlyContinue | Where-Object {
$_.PSChildName -match '^\w+\.\w+$' -and (Test-Path -Path "$($_.PSPath)\CLSID")
} | Select-Object -ExpandProperty PSChildName
This will output a list of all valid names of COM objects on your system sorted alphabetically, and the syntax is normally MainProgram.SubFunction.
Some of the output on my machine:
I hope this helps!
这篇关于win32com.client.Dispatch类标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!