python:创建2个com对象

问题描述:

我需要使用win32com远程连接到两台仪器,但创建第二个对象时出现错误。代码如下所示:python:创建2个com对象

scope1 = win32com.client.Dispatch("LeCroy.ActiveDSOCtrl.1") #creates first instance of the ActiveDSO control 
scope1.MakeConnection("GPIB:5") #Connects to device via GPIB 

scope2 = win32com.client.Dispatch("LeCroy.ActiveDSOCtrl.2") #creates a second instance of the ActiveDSO control 
scope2.MakeConnection("IP:127.0.0.1") #Connects to the oscilloscope on local host 

我在创建第二个COM对象时出现错误。 有没有人知道如何完成这项工作?

对于其他人谁是远程控制仪器的权益,该解决方案是简单的比预期: scope1 = win32com.client.Dispatch(“LeCroy.ActiveDSOCtrl.1”)#creates的ActiveDSO控制的第一个实例

scope1.MakeConnection(“GPIB:5”)#通过GPIB连接至设备 scope2 = win32com.client.Dispatch(“LeCroy.ActiveDSOCtrl.1”)#创建ActiveDSO控件的第二个实例
scope2.MakeConnection(“ IP:127.0.0.1“)#连接到本地主机上的示波器或任何其他IP地址

我实际上可以c reate尽可能多的ActiveX对象我想,只要我继续使用在调度相同的参考:“LeCroy.ActiveDSOCtrl.1”

发电机= win32com.client.Dispatch(“LeCroy.ActiveDSOCtrl.1”)

万用表= win32com.client.Dispatch(“LeCroy.ActiveDSOCtrl.1”) 。 。

我的错误是使用.2没有参考。