Reading a barcode when a program has no focus?

I like to write a simple program that reads the barcode, and also notes the barcode, as well as the time it was scanned. Unfortunately, I cannot guarantee that the program will have focus when checking the code. I understand that most barcode scanners act like a keyboard, so if the program has no focus, I will have problems. What are the ways to deal with this? Note. The identifier prefers to code this in Java, but I can use .net if the libraries simplify it. I also do not have a special scanner, so if one model works better for this, this information will be appreciated. Ive sceen this question , but suggests that the application has focus.

+7
java barcode
source share
3 answers

Most barcode scanners behave like a keyboard, so the processing application requires input focus. However, there are also barcode scanners that plug into a serial port or plug into a USB port and offer a virtual serial port interface.

These scanners must be accessible through a real or virtual serial port. For Java, you will need to use the Java Communication API or any other third-party library that offers access to serial ports, as this is not possible in the standard Java API.

+2
source share

Most keyboard barcode scanner keyboards can be configured (via configuration barcodes) to emulate a function key press before sending barcode data. The Windows API includes the RegisterHotkey function to define system-wide hotkeys. When the hotkey is pressed, you can specify the focus on the program window to read the barcode.

A Google search shows a library for registering hotkeys on an entire Java system. There is also a question on this site that seems to suggest that Mac OS X does not have a public library, although one of the respondents posted a link to the library that he was developing.

+2
source share

After some research on this subject that I implemented as jarnbjo mentioned in the virtual serial port, an example is here (see my answer).

0
source share

All Articles