473,701 Members | 2,638 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Identifying input from keyboard devices

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 were a keyboard. I need to
be able to identify input from the scanner and keyboard independently. I've
looked at DirectX.DirectI nput, and using user32.dll to hook into the
keyboard messages, but neither method seems to allow for identification of
the device sending the input. Inputs from either device are received and
there is not apparent difference.

Is there a way for either method (DI, or hooks) to identify which keyboard
device input is from? Or, is there another method that I overlooked?

(Note that the scanner cannot send pre-fixes, or be configured as a COM
device.)

Thanks in advance!
Don Riesbeck Jr.
Nov 16 '05 #1
7 10653
I knew I was going to forget something: This application will be running on
Windows 2000, Windows 2000 Server and potentially Windows XP.

Thanks Again

"Don Riesbeck Jr." <02************ ***********@ner dlycrap.com> wrote in
message news:eB******** *****@TK2MSFTNG P14.phx.gbl...
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 were a keyboard. I need to be able to identify input from the scanner and keyboard independently. I've looked at DirectX.DirectI nput, and using user32.dll to hook into the
keyboard messages, but neither method seems to allow for identification of
the device sending the input. Inputs from either device are received and
there is not apparent difference.

Is there a way for either method (DI, or hooks) to identify which keyboard
device input is from? Or, is there another method that I overlooked?

(Note that the scanner cannot send pre-fixes, or be configured as a COM
device.)

Thanks in advance!
Don Riesbeck Jr.

Nov 16 '05 #2
Are you in control of the Barcodes? If so, you can add a special code to
every encoded string for example, supppose the user can type "PRODUCT X" or
scan "PRODUCT X", the barcode could contain this instead "XXXProduct X" and
your code could always look for the first three starting characters and if
they are XXX then you can assume they came form a scanner.

JIM
"Don Riesbeck Jr." <02************ ***********@ner dlycrap.com> wrote in
message news:eB******** *****@TK2MSFTNG P14.phx.gbl...
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 were a keyboard. I need
to
be able to identify input from the scanner and keyboard independently.
I've
looked at DirectX.DirectI nput, and using user32.dll to hook into the
keyboard messages, but neither method seems to allow for identification of
the device sending the input. Inputs from either device are received and
there is not apparent difference.

Is there a way for either method (DI, or hooks) to identify which keyboard
device input is from? Or, is there another method that I overlooked?

(Note that the scanner cannot send pre-fixes, or be configured as a COM
device.)

Thanks in advance!
Don Riesbeck Jr.

Nov 16 '05 #3
I wish, but unfortunatly the barcode format is configurable, and must
support third party formats that do not have prefixes.

Thanks,
Don

"james" <no****@hyperco n.net> wrote in message
news:Ob******** ******@TK2MSFTN GP10.phx.gbl...
Are you in control of the Barcodes? If so, you can add a special code to
every encoded string for example, supppose the user can type "PRODUCT X" or scan "PRODUCT X", the barcode could contain this instead "XXXProduct X" and your code could always look for the first three starting characters and if
they are XXX then you can assume they came form a scanner.

JIM
"Don Riesbeck Jr." <02************ ***********@ner dlycrap.com> wrote in
message news:eB******** *****@TK2MSFTNG P14.phx.gbl...
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 were a keyboard. I need
to
be able to identify input from the scanner and keyboard independently.
I've
looked at DirectX.DirectI nput, and using user32.dll to hook into the
keyboard messages, but neither method seems to allow for identification of the device sending the input. Inputs from either device are received and
there is not apparent difference.

Is there a way for either method (DI, or hooks) to identify which keyboard device input is from? Or, is there another method that I overlooked?

(Note that the scanner cannot send pre-fixes, or be configured as a COM
device.)

Thanks in advance!
Don Riesbeck Jr.


Nov 16 '05 #4
I guess you are out of luck then. Data passed in through a wedge comes into
the PC through the keyboard interupt and appears to the computer exactly as
if it were typed. You should re-evaluate your reasons for why you need to
know this, and try to find a more generic way to handle it. i.e. A message
box that states "The scanned data is incorrect" could simply state "The
input data is incorrect" and your problem is solved.

JIM
"Don Riesbeck Jr." <02************ ***********@ner dlycrap.com> wrote in
message news:Oh******** ********@TK2MSF TNGP09.phx.gbl. ..
I wish, but unfortunatly the barcode format is configurable, and must
support third party formats that do not have prefixes.

Thanks,
Don

"james" <no****@hyperco n.net> wrote in message
news:Ob******** ******@TK2MSFTN GP10.phx.gbl...
Are you in control of the Barcodes? If so, you can add a special code to
every encoded string for example, supppose the user can type "PRODUCT X"

or
scan "PRODUCT X", the barcode could contain this instead "XXXProduct X"

and
your code could always look for the first three starting characters and
if
they are XXX then you can assume they came form a scanner.

JIM
"Don Riesbeck Jr." <02************ ***********@ner dlycrap.com> wrote in
message news:eB******** *****@TK2MSFTNG P14.phx.gbl...
> 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 were a keyboard. I
> need
> to
> be able to identify input from the scanner and keyboard independently.
> I've
> looked at DirectX.DirectI nput, and using user32.dll to hook into the
> keyboard messages, but neither method seems to allow for identification of > the device sending the input. Inputs from either device are received
> and
> there is not apparent difference.
>
> Is there a way for either method (DI, or hooks) to identify which keyboard > device input is from? Or, is there another method that I overlooked?
>
> (Note that the scanner cannot send pre-fixes, or be configured as a COM
> device.)
>
> Thanks in advance!
> Don Riesbeck Jr.
>
>



Nov 16 '05 #5
The Barcode scanner is not a "wedge" in the sense that it is inline with the
keyboard. The keyboard is PS/2 and the BC scanner is USB.

Our application must support input from the keyboard AND scanner. All
barcode data will be parsed by a library but keyboard input will just be
entered into the selected fields on the form.

There must be a way to at least detect that the scanner input is coming...

"james" <no****@hyperco n.net> wrote in message
news:O1******** ******@tk2msftn gp13.phx.gbl...
I guess you are out of luck then. Data passed in through a wedge comes into the PC through the keyboard interupt and appears to the computer exactly as if it were typed. You should re-evaluate your reasons for why you need to
know this, and try to find a more generic way to handle it. i.e. A message box that states "The scanned data is incorrect" could simply state "The
input data is incorrect" and your problem is solved.

JIM
"Don Riesbeck Jr." <02************ ***********@ner dlycrap.com> wrote in
message news:Oh******** ********@TK2MSF TNGP09.phx.gbl. ..
I wish, but unfortunatly the barcode format is configurable, and must
support third party formats that do not have prefixes.

Thanks,
Don

"james" <no****@hyperco n.net> wrote in message
news:Ob******** ******@TK2MSFTN GP10.phx.gbl...
Are you in control of the Barcodes? If so, you can add a special code to every encoded string for example, supppose the user can type "PRODUCT X"
or
scan "PRODUCT X", the barcode could contain this instead "XXXProduct X"

and
your code could always look for the first three starting characters and
if
they are XXX then you can assume they came form a scanner.

JIM
"Don Riesbeck Jr." <02************ ***********@ner dlycrap.com> wrote in
message news:eB******** *****@TK2MSFTNG P14.phx.gbl...
> 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 were a keyboard. I
> need
> to
> be able to identify input from the scanner and keyboard independently. > I've
> looked at DirectX.DirectI nput, and using user32.dll to hook into the
> keyboard messages, but neither method seems to allow for identification of
> the device sending the input. Inputs from either device are received
> and
> there is not apparent difference.
>
> Is there a way for either method (DI, or hooks) to identify which

keyboard
> device input is from? Or, is there another method that I overlooked?
>
> (Note that the scanner cannot send pre-fixes, or be configured as a

COM > device.)
>
> Thanks in advance!
> Don Riesbeck Jr.
>
>



Nov 16 '05 #6
Yes, there is. You must write your own driver for the USB device driver.
Then you can do anything you want. Or obtain the API from the vendor of
that device. How do you know for sure it is USB? I thought you said that
was outside your control? If the scanner IS inside your control, then you
can add a PREFIX to the actual scanner hardware so that every bit of scanned
text is pre-pended with some special code. How do you always know it iwl be
a USB scanner and not a serial one? Or a Keyboard wedge? Again, I would
ask what is your business case for needing to know? You will most likely
need to re-design your app.

JIM

"Don Riesbeck Jr." <02************ ***********@ner dlycrap.com> wrote in
message news:ec******** ******@TK2MSFTN GP15.phx.gbl...
The Barcode scanner is not a "wedge" in the sense that it is inline with
the
keyboard. The keyboard is PS/2 and the BC scanner is USB.

Our application must support input from the keyboard AND scanner. All
barcode data will be parsed by a library but keyboard input will just be
entered into the selected fields on the form.

There must be a way to at least detect that the scanner input is coming...

"james" <no****@hyperco n.net> wrote in message
news:O1******** ******@tk2msftn gp13.phx.gbl...
I guess you are out of luck then. Data passed in through a wedge comes

into
the PC through the keyboard interupt and appears to the computer exactly

as
if it were typed. You should re-evaluate your reasons for why you need
to
know this, and try to find a more generic way to handle it. i.e. A

message
box that states "The scanned data is incorrect" could simply state "The
input data is incorrect" and your problem is solved.

JIM
"Don Riesbeck Jr." <02************ ***********@ner dlycrap.com> wrote in
message news:Oh******** ********@TK2MSF TNGP09.phx.gbl. ..
>I wish, but unfortunatly the barcode format is configurable, and must
> support third party formats that do not have prefixes.
>
> Thanks,
> Don
>
> "james" <no****@hyperco n.net> wrote in message
> news:Ob******** ******@TK2MSFTN GP10.phx.gbl...
>> Are you in control of the Barcodes? If so, you can add a special code to >> every encoded string for example, supppose the user can type "PRODUCT X" > or
>> scan "PRODUCT X", the barcode could contain this instead "XXXProduct
>> X"
> and
>> your code could always look for the first three starting characters
>> and
>> if
>> they are XXX then you can assume they came form a scanner.
>>
>> JIM
>>
>>
>> "Don Riesbeck Jr." <02************ ***********@ner dlycrap.com> wrote in
>> message news:eB******** *****@TK2MSFTNG P14.phx.gbl...
>> > 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 were a keyboard. I
>> > need
>> > to
>> > be able to identify input from the scanner and keyboard independently. >> > I've
>> > looked at DirectX.DirectI nput, and using user32.dll to hook into the
>> > keyboard messages, but neither method seems to allow for identification > of
>> > the device sending the input. Inputs from either device are received
>> > and
>> > there is not apparent difference.
>> >
>> > Is there a way for either method (DI, or hooks) to identify which
> keyboard
>> > device input is from? Or, is there another method that I overlooked?
>> >
>> > (Note that the scanner cannot send pre-fixes, or be configured as a COM >> > device.)
>> >
>> > Thanks in advance!
>> > Don Riesbeck Jr.
>> >
>> >
>>
>>
>
>



Nov 16 '05 #7
I meant the barcodes themselves are outside of our control. (they are
supplied by vendors to our customers)

The application is a second generation of a product; we are set on the
machine, and have a couple USB scanners (we sell the whole thing.) We know
what scanners the current customers have, we sold them to them. Some of the
scanners support prefixing some don't we MUST support them all. The problem
is we have several different components which use barcodes and the code
currently used is very complicated. My hope was to have an object that just
monitored keyboard activity, and when it detected input from the barcode it
would simply set a property, and in the key pressed handler, we could just
have something like:

//Check for scan data
if (bcHook.isScan)
{
bctextBox.Text += e.KeyChar;
e.Handled = true;
return;
}

This would allow us to only worry about barcodes in the bctextBox field,
even if another textBox had focus.

I really only need to know if there was activity on the barcode scanner, I
don't need the actual data because it will come through the normal channels.

"james" <no****@hyperco n.net> wrote in message
news:u0******** ********@TK2MSF TNGP14.phx.gbl. ..
Yes, there is. You must write your own driver for the USB device driver.
Then you can do anything you want. Or obtain the API from the vendor of
that device. How do you know for sure it is USB? I thought you said that
was outside your control? If the scanner IS inside your control, then you
can add a PREFIX to the actual scanner hardware so that every bit of scanned text is pre-pended with some special code. How do you always know it iwl be a USB scanner and not a serial one? Or a Keyboard wedge? Again, I would
ask what is your business case for needing to know? You will most likely
need to re-design your app.

JIM

"Don Riesbeck Jr." <02************ ***********@ner dlycrap.com> wrote in
message news:ec******** ******@TK2MSFTN GP15.phx.gbl...
The Barcode scanner is not a "wedge" in the sense that it is inline with
the
keyboard. The keyboard is PS/2 and the BC scanner is USB.

Our application must support input from the keyboard AND scanner. All
barcode data will be parsed by a library but keyboard input will just be
entered into the selected fields on the form.

There must be a way to at least detect that the scanner input is coming...
"james" <no****@hyperco n.net> wrote in message
news:O1******** ******@tk2msftn gp13.phx.gbl...
I guess you are out of luck then. Data passed in through a wedge comes

into
the PC through the keyboard interupt and appears to the computer exactly
as
if it were typed. You should re-evaluate your reasons for why you need
to
know this, and try to find a more generic way to handle it. i.e. A

message
box that states "The scanned data is incorrect" could simply state "The
input data is incorrect" and your problem is solved.

JIM
"Don Riesbeck Jr." <02************ ***********@ner dlycrap.com> wrote in
message news:Oh******** ********@TK2MSF TNGP09.phx.gbl. ..
>I wish, but unfortunatly the barcode format is configurable, and must
> support third party formats that do not have prefixes.
>
> Thanks,
> Don
>
> "james" <no****@hyperco n.net> wrote in message
> news:Ob******** ******@TK2MSFTN GP10.phx.gbl...
>> Are you in control of the Barcodes? If so, you can add a special
code to
>> every encoded string for example, supppose the user can type
"PRODUCT X"
> or
>> scan "PRODUCT X", the barcode could contain this instead "XXXProduct
>> X"
> and
>> your code could always look for the first three starting characters
>> and
>> if
>> they are XXX then you can assume they came form a scanner.
>>
>> JIM
>>
>>
>> "Don Riesbeck Jr." <02************ ***********@ner dlycrap.com> wrote
in >> message news:eB******** *****@TK2MSFTNG P14.phx.gbl...
>> > 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 were a keyboard. I >> > need
>> > to
>> > be able to identify input from the scanner and keyboard

independently.
>> > I've
>> > looked at DirectX.DirectI nput, and using user32.dll to hook into the >> > keyboard messages, but neither method seems to allow for

identification
> of
>> > the device sending the input. Inputs from either device are received >> > and
>> > there is not apparent difference.
>> >
>> > Is there a way for either method (DI, or hooks) to identify which
> keyboard
>> > device input is from? Or, is there another method that I overlooked? >> >
>> > (Note that the scanner cannot send pre-fixes, or be configured as

a COM
>> > device.)
>> >
>> > Thanks in advance!
>> > Don Riesbeck Jr.
>> >
>> >
>>
>>
>
>



Nov 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1283
by: =WereWolf= | last post by:
Hi everybody, i'm working with many USB keyboards, which are recognized as HID keyboards on WinXP system. I need to handle input from all those keyboards, and identify the keyboard who is sending keystrokes. I tried with a DirectInput device enumeration, but it finds only one keyboard, unless i specify EnumDevicesFlags.IncludeAliases as
6
3161
by: Brian Basquille | last post by:
Hello all. Due to the short time remaining to my project handup for my Air Hockey game, i've abandoned the idea of implementing it over a network. But since the only real way to play Air Hockey is using a mouse, i was wondering if it is possible for 2 people to use 2 mouses while on the same computer? For example, 1 mouse could be in USB port and other in PS/2 port. Does C Sharp support this? And if so, can anyone point me to some...
0
6683
by: rs | last post by:
Hi guys, I am trying to read from a USB keyboard using vb.net and HID classes. the USB keyboard is not my primary keyboard. I have a ps2 keyboard connected and is detected in device manager as my keyboard. the USB keyboard is detected as HID keyboard device. the program finds the keyboard if it is attached. and I am getting valid handles. however, everytime I use the readfile function I am getting "object reference not set to an instant...
2
8761
by: rs | last post by:
Hi guys, I am trying to read from a USB keyboard using vb.net and HID classes. the USB keyboard is not my primary keyboard. I have a ps2 keyboard connected and is detected in device manager as my keyboard. the USB keyboard is detected as HID keyboard device. the program finds the keyboard if it is attached. and I am getting valid handles. however, everytime I use the readfile function I am getting "object reference not set to an instant...
3
10690
by: steve | last post by:
Hi All I need to write a program to read input from barcode scanner. The program is for a gym and needs to detect when a card is scanned regardless of which program is currently running ont he computer. e.g the operator might be typing a letter and a member swipes his card. I am convinced I need to write the card reader section as a Windows Service, so it is active always?
16
10930
by: dfaber | last post by:
Hi all, I have been searching for a keyboard and mouse tracker on linux. I've read solutions (watch at sourceforge) which look at /proc/interrupts to check keyboard or mouse activity. I also read one post where "watch" seems to have difficulty tracking usb keyboards and mice. So, I'm out of ideas here. My goal are: 1. Check keyboard activity. I'm not interested in logging which keys are pressed or record them.
5
7409
by: Sagaert Johan | last post by:
Hi Can someone point me the good direction to start a project that injects keycodes, or (scancodes ) into the system as if the came from the keyboard. (like barcodescanners etc.. do) Johan
4
20219
by: Gerry19 | last post by:
Hi All, I'm trying to monitor data passed from a USB Barcode scanner but I can't find any decent code examples of what I need to do, including any references I need to include. I know I need to use RegisterRawInputDevices & WM_INPUT but have no idea where to start. Any help greatly appreciated.
4
5067
by: Newbie | last post by:
Hello I need to enter a string of the form abc (a string of characters followed by EOF) #include<stdio.h> #include<stdlib.h> #include<string.h> #define MAX 100 int main(void) {
0
8736
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8649
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8934
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7824
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6571
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4410
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2398
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2035
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.