none
Pen Stroke Counter RRS feed

  • Question

  • I am trying to create a program that will count the number of pen strokes input to any program not just mine (something kind of like a keystroke logger). The program that will eventually use the counting will be written in C# but I'm sure I will need to write some C++ code to get this done.

    I was looking into how to create a low level hooks and found this example for mouse and keyboard hooks.

    http://www.codeproject.com/KB/system/globalsystemhook.aspx

    I tried modifying this a bit to detect pen input. I was able to get the pen events when my app had focus but I didn't get any events when my app didn't have focus.

    Any ideas on how to go about this would be appreciated.

    Thanks,

    Nolan

    Saturday, August 21, 2010 3:31 AM

All replies

  • I'm kicking this thread again with a bit more info and a sample application.

    I have created a simple windows form app that listens for mouse messages and displays two things. First the x and y position of the mouse and second if the message came from a mouse or a pen.

    To determine if the mouse message is from a pen or not, I'm using the technique described here:  http://msdn.microsoft.com/en-gb/library/ms703320(VS.85).aspx. This involves calling GetMessageExtraInfo(), masking the return value with 0xFFFFFF00 and checking if it's equal to 0xFF515700. 

    The problem I'm running into is that the mouse messages only indicate they are from a pen if the cursor is over my application. If I hover the pen outside of my application or if my application doesn't have focus then GetMessageExtraInfo() returns 0.

    Is there any why to determine if a mouse message is from a pen if my application does not have focus?

    Here is a link to a zip of the apps solution:

    http://cid-d0817828920642df.office.live.com/self.aspx/Public%20Share/PenHookTest.zip

    Any insights of what's going on here or suggestions of what else to try would be appreciated.

    Thanks,

    Nolan

    Sunday, January 9, 2011 1:45 AM