0

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.

Glenn Maynard
  • 55,829
  • 10
  • 121
  • 131
DamonJW
  • 3,342
  • 2
  • 24
  • 29
  • I have no idea on the answer, but I'd suggest some more tags, like Windows-7, or whatever seems more appropriate to you. Except for finding a Python interface to RealTimeStylus, this doesnt' involve much Python; and maybe even you'd want to break off this Python part into a separate question, as more people will read one sentence than thirty. (Though I might be wrong here so make your own more informed choice.) – tom10 Sep 29 '09 at 01:42
  • It wouldn't make sense to filter for double-clicks--apps don't examine multiple MOUSEDOWN events to detect double-clicks; that's what WM_LBUTTONDBLCLK, etc. are for. I don't know what's up, but for diagnostics I'd suggest seeing if this happens with a mouse; see it it happens in XP; log WM_MOUSEMOVE events as well as WM_MOUSEDOWN events and see if anything stands out; see if there's anything similar to XP's "enhance pointer precision" setting somewhere in Win7's scrambled, useless control panels. – Glenn Maynard Sep 29 '09 at 02:54

1 Answers1

1

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
  • 97,548
  • 12
  • 110
  • 164