Hi all,

I am trying to port a piece of software from win32com to comtypes, 
because that's what we use in our project. Basically, I want to react on 
events generated by the Synaptics touchpad. Unfortunately, ShowEvents() 
doesn't show me actually any events when I generate them (e.g. press 
buttons or move fingers on the touchpad). On the other side, I can 
successfully consume events when use win32com package.
When I call ShowEvents on an object, it shows me that there is one event 
(OnPacket), but it doesn't notify when packet arrives.

Here are two little scripts, first uses win32com, and second uses 
comtypes. If you have Synaptics touchpad (Almost every notebook/netbook 
has it), run the scripts and try to perform something with your touchpad 
to generate events.

#testpad_old.py
from win32com.client import Dispatch, DispatchWithEvents, constants
import pythoncom

class SynDeviceTouchPadCtrlEvents:
     def OnPacket(self):
         print "on packed is called"

api = Dispatch('SynCtrl.SynAPICtrl')
api.Initialize()
api.Activate()
handle = api.FindDevice(constants.SE_ConnectionAny, 
constants.SE_DeviceTouchPad, -1)
if handle < 0:
     raise RuntimeError('Can\'t find a TouchPad device!')
touchpad = DispatchWithEvents('SynCtrl.SynDeviceCtrl', 
SynDeviceTouchPadCtrlEvents)
touchpad.Select(handle)
touchpad.Activate()
pythoncom.PumpMessages()


#testpad_new.py
from comtypes.client import CreateObject, ShowEvents, PumpEvents
import comtypes.gen.SYNCTRLLib as synlib

api=CreateObject('SynCtrl.SynAPICtrl')
api.initialize()
api.activate()
handle = api.FindDevice(synlib.SE_ConnectionAny, 
synlib.SE_DeviceTouchPad, -1)
if handle < 0:
     raise RuntimeError('Can\'t find a TouchPad device!')
touchpad=CreateObject('SynCtrl.SynDeviceCtrl')
conn=ShowEvents(touchpad) # event found: _ISynDeviceCtrlEvents_OnPacket
touchpad.select(handle)
touchpad.Activate()
PumpEvents(10)


I am using comtypes version 0.6.2. Is it a comtypes bug or mine?

Thanks,
Lex

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to