[python-win32] COM event doesn't received

jh_wang2004 jh_wang2004 at 163.com
Fri Dec 26 09:25:18 CET 2014


Hi all:
    I use win32com to receive a com event,but it does not work,the code is:
import win32com.client 
import pythoncom
import win32com.client.makepy
class TrackingEvent(object):
    def IdentifyTire(self):
        print 'IdentifyTire event detected'
    def TireIsActivated(self, Tirecode, Customercode):
print '***TireIsActivated Event***'
class SystemEvent(object):
    def MainShutdown(self):
        print 'TQC Quit detected'
    def AlarmReceived(Caption='r1', Category='r2', Message='r3'):
        print 'alarm received!'


mod = win32com.client.gencache.EnsureModule("{1CB6D73B-9242-42E7-86C0-E2E4B06B1419}", 0, 1, 0)
print dir(mod)
ob1 = mod.RQPTireTracking()
ob3 = mod.RQPSystem()
ob1_Tracking = win32com.client.DispatchWithEvents(ob1, TrackingEvent)
ob3_System = win32com.client.DispatchWithEvents(ob3, SystemEvent)
print 'machinetype is:', ob3_System.GetMachineType()
pythoncom.PumpMessages()


    when the code running, it seems corectliy without error, invock method GetMachineType return a normal value, and .PumpMessages blocked for event receiving, but the two event handler does not receive any events, while at same time a VB  and VC++ client using the same COM interface receive all events that  COM broadcasts. I modify the code,directly dispatch the class without using gencache
ob1_Tracking = win32com.client.DispatchWithEvents("UCI.RQPTireTracking", TrackingEvent)
ob3_System = win32com.client.DispatchWithEvents("UCIRQPSystem", SystemEvent)
it out put the same result as first one,
    So any one can give me a hit to track down this problem?
Thanks a lot for your help
Cheers,
jianhua



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20141226/76ade591/attachment.html>


More information about the python-win32 mailing list