Forum > Windows

Win 10 IoT Getting USB Barcode reader data without holding focus on TEdit



I have another problem with sneaky win 10.
I need to get barcode reader data always, so far i havent found good solution. Win does not allow open keyboard as HID device.

System at the moment: Small PC, no internet, no display, no keyboard, no other user input. Only Barcode reader.
All windows messages and notifications are turned off.

Cursor is automatically set to edit box at program start, also program has implemented automatic focusing system in case application will be deactivated.

But windows is sneaky bastard. It may trigger some ridicolus message or notification, eg lets set thing up, lets finish setup, better user experience and so on.
My program triggers automatic focus gain, application will be activated, takbar icon is yellow colored but that poor input will not transfer where it meant to be and no scanner data.

Refocusing code is:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Timer1Timer(Sender: TObject);var  I: LPInput;begin   Timer1.Enabled:= False;// timer activated focus regain code   if Self.cbAutoFocusHold.Checked = False then // checkbox unchecked, ignore auto focusing    Exit;   I := nil;  try    // Hack #2: send myself some dummy input    GetMem(I,SizeOf(Input));    FillChar(I^, SizeOf(Input),$00); // empty input structure    SendInput(1, I, SizeOf(Input));    SetForegroundWindow(Application.MainForm.Handle);  finally    if I <> nil then FreeMem(I,SizeOf(Input));  end;  SetActiveWindow(Self.Handle);  edBarcodeInput.SetFocus;  memLog.Lines.Add('refocused');end; 
Maybe there is something wrong with the focus grab code, but better way is get barcode data directly.
Also there is no VSP entry in device manager.

Any help/idea/sugestion is very welcomed.

Besides providing a keyboard driver, many bar code readers also provide DLL based SDK that you can use instead. However, if that is not the case then you might consider using system or form based keyboard hook.,54914.0.html

Remember: Many Barcode-Readers offer a (simulated?) "serial COM-Port (RS232)"-Mode....
Then it's just reading the Byte-"Stream" coming in there..... independant, if the App has Focus or not....

Yes, I posted the question and walked away from computer and then I figured out that I can reconfigure scanner to act as usb-serial port.
Novadays scanners have everything built in - just scan specific code supplied by vendor and voila, now it is usb-serial device.
Also serial is something I use every day, I mostly work with microcontrollers (Microchip PIC series, ARM Embedded and so on) and serial is main communication interface with PC.
But I will study key hook too, for the future projects.

Thanks for answering my question.


[0] Message Index

Go to full version