Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8729991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:56:01+00:00 2026-06-13T08:56:01+00:00

I’m making a driver for a barcode scanner. This particular scanner is basically a

  • 0

I’m making a “driver” for a barcode scanner.

This particular scanner is basically a USB keyboard that generates keystrokes whenever something is scanned.

I want to find a way to distinguish these keystrokes from those keystrokes a proper keyboard sends. Unfortunately the only difference is that scanner generates keystrokes really fast, a bunch of keyups and keydowns in a fraction of a second.

The way I see it is I have to set up a global keyboard hook that intercepts all input, stores it somehow, waits for a tiny bit then either sends those keystrokes further down the hook chain or assumes they are something that scanner generated and handles them appropriately.

However, having no prior experience with hooks, I am not sure about the right way to do it. Can I just invoke CallNextHookEx() in some method other than KeyboardProc() in some other thread to pass the delayed keystroke event? Or should I rather generate a new WM_KEYPRESS message manually? Maybe there is an altogether better way to go about this thing?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:56:03+00:00Added an answer on June 13, 2026 at 8:56 am

    Ok, here is my solution in case someone encounters a similar problem.

    First, use WH_KEYBOARD_LL hook instead of WH_KEYBOARD.

    Second, use SendInput() API function to pass keystrokes you don’t need to the active window.

    Third, low level keyboard hook’s callback function has a pointer to KBDLLHOOKSTRUCT as one of the parameters; use LLKHF_INJECTED bit in its flags bitfield to distinguish real keystrokes from the ones you’ve just generated. If you are paranoid and afraid someone else might be pulling the same trick, use the dwExtraInfo member of the structure both SendInput() and hook callback use to distinguish keystrokes that are injected by yourself and by someone else.

    Fourth, be aware that Windows 7 tends to silently unhook a low-level hook if it takes too long to process the input, so either keep the hook callback as simple and possible and be sure to pump the Windows message queue as often as possible in the thread that hooked the hook; or – if you’re a bad bad boy – there is a registry key at HKCU\Control Panel\Desktop\[DWORD]LowLevelHooksTimeout, setting it to a reasonably large value might work too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.