PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Stylus interception

Dave Johnston · 05 May 2003, 00:40 UTC
Err, anyone have any idea how to intercept screen taps/input? Or to put it another more precise way, does anyone know how to take screen input x/y coords, fiddle with their value, then pass them through to the PPC GUI as if nothing ever happened?

The idea being that with such an ability, stylus input could be mirrored invisibly to the user, or indeed manipulated in a far more sensible way :)

I'm sure it's possible - but not sure if it's feasible. I guess Nyditot does a similar thing when it changes/rotates the screen size, but I'm not sure if that's actually an internal kernel operation it uses.

Basically I'd just like to create a more flexible screen alignment tool. Simple, in theory...

Anyone have any ideas or suggestions? I tried the obvious places the best I could, but now I'm all out of leads! :?
I am somewhat confused to what you are trying to do. Are you trying to intercept the input before the GUI interperates it, then feeding it back to the GUI to produce different input methods?
off the top of my head...
are you trying to do this globaly? you can probably make an invisible widow and do a SetCapture(); on the mouse (which is the stylus) and then get the active window handle and pass the altered message through to it. don't think that is the brightest way to do it though...
Dave Johnston · 05 May 2003, 09:43 UTC
DillRye wrote:
I am somewhat confused to what you are trying to do. Are you trying to intercept the input before the GUI interperates it, then feeding it back to the GUI to produce different input methods?


That's... a far better way to describe what I was thinking of, yes! :)

I mean, as an example, I would like to be able to write a program that is 'always' running in the background (like WISBar) and manipulates all stylus input so that input is - for example - mirrored, in any application (well, 95% of apps) the user may choose to run. Similarly I could create an app that means only the bottom half of the screen actually accepts any input using the same technique.

I don't mean it to sound as malicious as it does :)
Look up GetCapture in MSDN help. Use that in conjunction with GetForegroundWindow.
Dave Johnston · 07 May 2003, 09:48 UTC
Thanks, I'll look into that... just once I've got my airport simulator demo'd.... arghr...
That would be cool to have if you lent your PPC out to a friend or family member. You could see everything they tapped.

Once I let my little brother use my PPC and several days later I used it and saw that he had searched for "porn." Luckily none was on there. Hehe. :D
You can always try playing with 'fake' window messages. I once coded a program that tricked a paint application on a website (an oekaki board) to think the user was drawing an image, pixel-per-pixel, by sending thousands of 'fake clicks' to it's HWND.
All I had to do was find the target window using FindWindow(), and then use SendMessage() with WM_LBUTTONDOWN/WM_LBUTTONUP to make it think the user was clicking.

There is a pretty simple way to send a message to all opened windows (excluding their children) in the OS, it's called message broadcasting. For example, by specifying HWND_BROADCAST in SendMessage() all top-level windows receive the message.

Intercepting the stylus should be a bit harder. I haven't ever tried this, but there may be a way to use subclassing for that. If there was an OS-driven window that receives the input and broadcasts it to all other windows, you theorically could subclass it and voila, get control over what the PDA receives from the stylus.

Check MSDN for further information about that. But remember to be careful in playing with such a primary thing like stylus input.


Oh, and if you want a handy tool for some training and testing of how the windows react to window messages, you can use this utility I once wrote:

http://justt.cellosoft.com/files/PostMsg.exe

This is a PC build, but I can give you it's source so you can port it to PPCs, if you're interested.

I hope this helps :)
Dave Johnston · 11 May 2003, 10:45 UTC
Awesome stuff - thanks!

I don't actually mean to try any of this stuff just yet (other work taking priority), but in a few weeks time. I'll post my progress then, but in the meantime, ta for all the advice and pointers. I'm still hoping it's all possible (and in theory, stylus interception should be the easy part of my little project!)

Guess I ought to read up on MFC too...