By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,263 Members | 1,503 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,263 IT Pros & Developers. It's quick & easy.

Identifying input from keyboard devices

P: n/a
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.DirectInput, 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
Share this Question
Share on Google+
7 Replies


P: n/a
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***********************@nerdlycrap.com> wrote in
message news:eB*************@TK2MSFTNGP14.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.DirectInput, 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

P: n/a
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***********************@nerdlycrap.com> wrote in
message news:eB*************@TK2MSFTNGP14.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.DirectInput, 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

P: n/a
I wish, but unfortunatly the barcode format is configurable, and must
support third party formats that do not have prefixes.

Thanks,
Don

"james" <no****@hypercon.net> wrote in message
news:Ob**************@TK2MSFTNGP10.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***********************@nerdlycrap.com> wrote in
message news:eB*************@TK2MSFTNGP14.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.DirectInput, 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

P: n/a
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***********************@nerdlycrap.com> wrote in
message news:Oh****************@TK2MSFTNGP09.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****@hypercon.net> wrote in message
news:Ob**************@TK2MSFTNGP10.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***********************@nerdlycrap.com> wrote in
message news:eB*************@TK2MSFTNGP14.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.DirectInput, 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

P: n/a
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****@hypercon.net> wrote in message
news:O1**************@tk2msftngp13.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***********************@nerdlycrap.com> wrote in
message news:Oh****************@TK2MSFTNGP09.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****@hypercon.net> wrote in message
news:Ob**************@TK2MSFTNGP10.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***********************@nerdlycrap.com> wrote in
message news:eB*************@TK2MSFTNGP14.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.DirectInput, 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

P: n/a
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***********************@nerdlycrap.com> wrote in
message news:ec**************@TK2MSFTNGP15.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****@hypercon.net> wrote in message
news:O1**************@tk2msftngp13.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***********************@nerdlycrap.com> wrote in
message news:Oh****************@TK2MSFTNGP09.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****@hypercon.net> wrote in message
> news:Ob**************@TK2MSFTNGP10.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***********************@nerdlycrap.com> wrote in
>> message news:eB*************@TK2MSFTNGP14.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.DirectInput, 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

P: n/a
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****@hypercon.net> wrote in message
news:u0****************@TK2MSFTNGP14.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***********************@nerdlycrap.com> wrote in
message news:ec**************@TK2MSFTNGP15.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****@hypercon.net> wrote in message
news:O1**************@tk2msftngp13.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***********************@nerdlycrap.com> wrote in
message news:Oh****************@TK2MSFTNGP09.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****@hypercon.net> wrote in message
> news:Ob**************@TK2MSFTNGP10.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***********************@nerdlycrap.com> wrote
in >> message news:eB*************@TK2MSFTNGP14.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.DirectInput, 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 discussion thread is closed

Replies have been disabled for this discussion.