views:

251

answers:

1

How can I tell Windows not to do unhelpful pre-processing on tablet pen events?

I am programming in Python 2.6, targetting tablet PCs running Windows 7 (though I would like my program to work with little modification on XP with a SMART interactive whiteboard, and for mouse users on Linux/Mac). I've written a program which hooks into the normal Windows mouse events, WM_MOUSEMOVE etc., and writes on a canvas.

The problem is that the mouse messages are being fiddled with before they reach my application. I found that if I make long strokes and pause between strokes then the mouse messages are sent properly. But if I make several rapid short strokes, then something is doing unhelpful pre-processing. Specifically, if I make a down-stroke about 10 pixels long, and then make another downstroke about five pixels to the right of the first, then the second WM_MOUSEDOWN reports that it comes from exactly the same place as the first.

This looks like some sort of pre-processing, perhaps so that naive applications don't get confused about double-clicks. But for my application, where I want very faithful response to rapid gestures, it's unhelpful.

I found a reference to the MicrosoftTabletPenServiceProperty atom, and to CS_DBLCLKS window style, and I turned them both off with the following piece of Python code:

hwnd = self.GetHandle()  
tablet_atom = "MicrosoftTabletPenServiceProperty" 
atom_ID = windll.kernel32.GlobalAddAtomA(tablet_atom)  
windll.user32.SetPropA(hwnd,tablet_atom,1)  
currentstyle = windll.user32.GetClassLongA(hwnd, win32con.GCL_STYLE)  
windll.user32.SetClassLongA(hwnd, win32con.GCL_STYLE, currentstyle & ~win32con.CS_DBLCLKS)

But it has no effect.

I tried writing a low-level hook for the mouse driver, with SetWindowsHookEx, but it doesn't work -- obviously the mouse messages are being pre-processed even before they are sent to my low-level Windows hook.

I would be very grateful for advice about how to turn off this pre-processing. I do not want to switch to RealTimeStylus -- first because it won't work on Windows XP plus SMART interactive whiteboard, second because I can't see how to use RealTimeStylus in CPython, so I would need to switch to IronPython, and then my code would no longer run on Linux/Mac.

Damon.

A: 

For raw mouse messages, you can use WM_INPUT on XP and later. Seven added some touch specific stuff: WM_GESTURE and WM_TOUCH

Anders
This is exactly what I was looking for. Thank you.
DamonJW