条形码扫描仪键盘挂钩. [英] Barcode Scanner keyboard hooks.
问题描述
伙计们,
我需要集成一个条形码扫描器,该条形码扫描器的作用类似于没有应用程序的USB键盘.我们的应用程序具有一个现有的低级键盘挂钩,其创建方法如下:
:: SetWindowsHookEx(WH_KEYBOARD_LL,LLKeyboardHook,hModule,0);
这里的问题是此低级键盘挂钩无法捕获条形码扫描器模拟的按键.如果我使用"WH_KEYBOARD"钩子类型创建钩子,则可以从条形码扫描仪获得正确的输入.但是由于某些限制,我将无法使用这种类型的钩子.
这是捕获条形码扫描仪输入的正确方法吗?应该做更多的事情吗?我希望条形码扫描器可以像键盘一样工作,因此应该将其卡在现有的键盘挂钩中.
有人遇到过这个问题吗?任何想法或示例代码都将受到高度赞赏.
预先感谢.
Folks,
I need to integrate a barcode scanner that acts like a USB keyboard with out application. Our application has an existing low level keyboard hook that is created as follows
::SetWindowsHookEx( WH_KEYBOARD_LL, LLKeyboardHook, hModule , 0);
The problem here is that this low-level keyboard hook is unable to capture the key presses emulated by the barcode scanner. If I create the hook using the "WH_KEYBOARD" hook type , then I am able to get the correct input from the barcode scanner. But due to certain constraints, I wouldnt be able to use a hook of this type.
Is this the correct way to trap the input from a barcode scanner? Should anything more be done? I was hoping that since the barcode scanner would act like a keyboard, it should get trapped in the existing keyboard hook.
Anyone faced this problem before? Any thoughts or sample code is highly appreciated.
Thanks in advance.
推荐答案
跳过键盘挂钩,并使用 OPOS或NPOS [^ ]
OPOS确实非常易于使用,可能比您当前的方法要容易得多.
或查看条形码扫描 [
Skip the keyboard hook and use an API like OPOS or NPOS[^]
OPOS is really easy to use, probably significantly easier than your current approach.
Or take a look at Barcode scanning[^] - look at revision 1 for a more complete version of the code. Allows you to easlily read barcodes from a Symbol barcode scanner connected to the serial port. All you need is to implment a single event handler.
Regards
Espen Harlinn
这篇关于条形码扫描仪键盘挂钩.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!