Filtering key strokes

Z

zed

Hi,

having a card reader attached to the PS/2 keyboard interface, I would
like to filter the keyboard input, so that the input from the card
reader does not reach the GUI controls.

I tried setting KeyPreview=true on the form and catched all input with
the KeyDown event. In order to detect, if the input comes from the
card reader, I need to check a sequence of at least 10 keys. So I
collect the keys in KeyDown and if it's a card reader sequence, I
trigger a special action for it. If it's normal user input, I need to
"forward" the collected key strokes to the form.

The second part is the complicated one. Having a sequence of key
strokes in an array of type System.Windows.Forms.Keys, how do I resend
these to the application? Sendkeys only accepts a string and seems to
not support all values of the System.Windows.Forms.Keys enum.

Is there maybe a way to resend keystrokes using the integer values
captured from the KeyValue member of the KeyEventArgs?

bye,

Marc T.
 
J

Jim Hughes

Every card reader that I've used that goes in line with the keyboard
provides input that is indistinguishable from the real keyboard.

The only successful solution that I have found is to use a non keyboard
interface for example, a serial port.
 
Z

zed

I couldn't find a nice solution so I now assume, that the card reader
(or iButton key lock) sends a hotkey that is not allowed to be used
for any other purpose. When the form detects the hotkey in KeyDown, it
hides the key strokes from the controls and collects them until a
small timeout is triggered. The collected keystrokes are then matched
against a Regexp and appropriate action is taken. It works with the
hardware I currently use, but might be a problem the future.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top