Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Hardware & Devices
  4. How can I [quickly] differentiate a USB card reader impersonating a keyboard, from the real keyboard?

How can I [quickly] differentiate a USB card reader impersonating a keyboard, from the real keyboard?

Scheduled Pinned Locked Moved Hardware & Devices
csharpdatabasequestionwinformsjson
3 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Neophyte30
    wrote on last edited by
    #1

    Scenario: I have a USB RFID card reader. It pretends to be a keyboard (HID Keyboard Device) and when a card is swiped, it 'types' the card serial followed by return in to whichever application has focus. I need to capture the serial coming from the reader so I can store arrival and departure times of cards in a database. I have been given 2 (two) days to come up with a demo of this technology for one of our customers! Possible Options: 1) win32 api calls to hook keypresses: I have this working, globally, as I would like it to, but has the disadvantage of capturing keypresses from the standard keyboard - I'm assuming this is not at a low enough level to distinguish between PS/2 and USB keyboards. 2) wmi calls to access the usb device directly: I'm not really sure where to start with this - My language of preference is C#, and it looks like it might be a lengthy task to wrap these calls 3) fake it! Make sure that my demonstrator (a colleague) knows to ensure that the 'scanner' app has focus, and that he should not touch the standard keyboard. I can use standard winforms key events, and even fake the back end DB if necessary. Any suggestions, pointers to tutorials gratefully received!

    L 1 Reply Last reply
    0
    • N Neophyte30

      Scenario: I have a USB RFID card reader. It pretends to be a keyboard (HID Keyboard Device) and when a card is swiped, it 'types' the card serial followed by return in to whichever application has focus. I need to capture the serial coming from the reader so I can store arrival and departure times of cards in a database. I have been given 2 (two) days to come up with a demo of this technology for one of our customers! Possible Options: 1) win32 api calls to hook keypresses: I have this working, globally, as I would like it to, but has the disadvantage of capturing keypresses from the standard keyboard - I'm assuming this is not at a low enough level to distinguish between PS/2 and USB keyboards. 2) wmi calls to access the usb device directly: I'm not really sure where to start with this - My language of preference is C#, and it looks like it might be a lengthy task to wrap these calls 3) fake it! Make sure that my demonstrator (a colleague) knows to ensure that the 'scanner' app has focus, and that he should not touch the standard keyboard. I can use standard winforms key events, and even fake the back end DB if necessary. Any suggestions, pointers to tutorials gratefully received!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I believe you can use the Raw Input[^] functions to register for raw keyboard input and differentiate those keystrokes. There is a sample of its usage here on codeproject: Using Raw Input from C# to handle multiple keyboards[^] Best Wishes, -David Delaune

      N 1 Reply Last reply
      0
      • L Lost User

        I believe you can use the Raw Input[^] functions to register for raw keyboard input and differentiate those keystrokes. There is a sample of its usage here on codeproject: Using Raw Input from C# to handle multiple keyboards[^] Best Wishes, -David Delaune

        N Offline
        N Offline
        Neophyte30
        wrote on last edited by
        #3

        Thanks for this - I had a look and decided it was a bit too involved for a demo - I've gone with option 3 (fake it!) for now, so I can get back to my main project! Cheers, Al

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups