473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

capture & analyze keyboard input

maxx233
32
No, I'm not trying to make a keylogger ;) I need to be able to swipe a MagStripe card through a reader (which uses the standard keyboard driver), and when it reads a string of 20 characters being input in rapid succession (under 300ms) *not* send that string to the active application, but instead do some processing on it first, and send the processed data to the active app.

So basically to finish this little project I need to figure out how to route keyboard data through an invisible background app *before* it hits the active application.. This way I can find the string in question and not ever send that data to the active app (it's useless until the processing has been done to convert it.) Is there a way to do this? From there I can figure the rest out, but I'm having difficulty with this part :\ Thanks!

maxx
Dec 18 '08 #1
5 9259
nukefusion
221 Expert 100+
You don't mention whether your application is a windows forms program or just a console application.

If it's a WinForms program you might be able to capture the key presses at the form level using the KeyPress event and do the processing there. You would probably want to put the application into a waiting state before scanning the card so that the program would be expecting the input. That way you could avoid scanning and checking every single keypress.

If that doesn't work or isn't possible you could use P/Invoke to set up a keyboard hook. You'd need to use the SetWindowsHookEx and UnhookWindowsEx functions.
Dec 18 '08 #2
tlhintoq
3,525 Expert 2GB
It sounds a like a program to intercept the reading of credit cards or security access cards, because you want to transparently read and 'process' the card data then send it on to the active application as if nothing had happened.

Keyboard wedges are pain for something like this. The input can't be differentiated from true keyboard input. It goes to the control that has focus, so when you say you want to pass the data along to the "active application"... Your MagCard reader program would *be* the active application if it is receiving the card swipe as keyboard input. You would have to identify the receiving application in some way (process name?) then send the data to it.

If you work out a way to intercept ALL keyboard input on the PC so that you can get the MagCard keyboard wedge input, you then have to decide if what you are receiving is coming from the Keyboard or from the KeyboardWedge.

All in all, its a clunky bandaid. I take it the "active application" you want to send it to isn't a program you are writing?? If it were, it would be better to include the processing inside the application meant to receive the data.

I would recommend at the very least to change MagCard readers to a non-keyboard wedge. A serial port reader would let you monitor the reader separate from the keyboard.
Dec 19 '08 #3
Plater
7,872 Expert 4TB
Worrying about which keyboard input device aside, you can probably capture the input with a "global hook"
CodeProject: Processing Global Mouse and Keyboard Hooks in C#. Free source code and programming help

As for the deciding what came from where, you might be able to query the WMI about which device is sending the keyboard inputs, but I doubt it.
I also don't know if those global hooks will be fast enough for you to see your 300ms
Dec 19 '08 #4
maxx233
32
Well - The good news is that we really don't need to worry about about deciphering what's coming from where. The application will be on a tablet PC basically only with mouse input, aside from this Mag reader which registers as a keyboard. The bad news is that you're correct tlhintoq - the active app isn't one I've written, and the vendor doesn't provide any API that I could just shoot directly to it and control some other aspects. I've tested SendKeys.Send() and that seems to work from the background with some static text being written to the active app - so as long as the user has the correct field selected in that app when they swipe the card that aspect should work at least. I'll check out that CodeProject page Plater - I've seen it come up on google but wasn't entirely sure that was what I was going for or not, so I guess I'll just give it a try and find out that way. I'll report back - thanks!
Dec 19 '08 #5
look at Keystroke Spy Monitor it may be helpful
Apr 23 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Astra | last post by:
Hi everybody Wonder if you could help me out. I created a simple JavaScript routine to enable a user to click backwards and forwards between small news articles. This routine works fine in IE...
3
by: Harry Broomhall | last post by:
I asked earlier about ways of doing an UPDATE involving a left outer join and got some very useful feedback. This has thrown up a (to me) strange anomaly about the speed of such an update. ...
12
by: Merrill & Michele | last post by:
It's very difficult to do an exercise with elementary tools. It took me about fifteen minutes to get exercise 1-7: #include <stdio.h> int main(int orange, char **apple) { int c; c=-5;...
7
by: Don Riesbeck Jr. | last post by:
I'm working on an application (OEM) using C# that utilizes input from a keyboard, and USB Barcode Scanner. The scanner is a HID Keyboard device, and input from it is sent to the system as if it...
2
by: TC | last post by:
Hello, I need to build a very simple text editor. The requirement is that the input screen should be divided into 'm*n' cells ('m' rows, 'n' columns, with each cell of a fixed size). Whenever...
0
by: neonspark | last post by:
I'm buidling some simple macro functionality for my app so the users can record a sequence of keyboard inputs and replay them reliably via some menu. Originally, I used: protected override bool...
14
by: arnuld | last post by:
i have slightly modified the programme from section 1.5.1 which takes the input frm keyboard and then prints that to the terminal. it just does not run and i am unable to understand the error...
5
jamesd0142
by: jamesd0142 | last post by:
hi guys i want to create a form which runs in the background which is not visible... so far so good... now... how can i get it to capture all keyboard input, so that i can say if f10 is pressed...
3
by: Blip | last post by:
Hello - I'm trying to wite these control characters to the serial port w/o success. I've tried sp.Write((Keys.ControlKey & Keys.X).ToString()); sp.Write((Keys.Control & Keys.X).ToString()); ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.