What are the various ways to access devices on client PC - a barcode reader, a scanner, etc. - from a browser? I realize my users may need a plugin. These devices may have an API that is specific to their device; I would like to exploit their API if available (maybe Java, maybe C, maybe command line).
A signed Java applet can have platform-independent access to most things. The user has to have Java installed, and has to allow the signed applet to run.
If you write a plug-in to the NSAPI, once they've installed it you'll have access to essentially anything the user can access. Of course, they have to install the plug-in.
Flash offers quite a lot of access to devices.
This is not a trivial thing, and there is no standardized API for it (except maybe in the JScript/ActiveX area that is confined to Internet Explorer).
For accessing scanners through the TWAIN interface, check out this question for all generally available options I know of.
Most other things will be down to custom programmed Active-X and other plug-ins. I have seen commercial barcode scanner plug-ins discussed on SO, but can't find the question right now.
Many barcode readers can be inserted between the keyboard and the PC, so the scanned barcodes go straight into the keyboard buffer. Other devices either plug into a serial port or have drivers that emulate a serial port. The following python code will copy data from a real or virtual COM port to the keyboard buffer of the active window. The COM port number is hard-coded but this can easily be changed.
import serial
import SendKeys
ser = serial.Serial(2)
print ser.portstr
while 1: # exit loop when ctrl/c pressed
line = ""
while 1:
char = ser.read()
if char == "\r": break
line = line + char
print line
SendKeys.SendKeys(line, 0)
ser.close()
Depending on what you are trying to do, Silverlight and Adobe both have some limited capability in this arena. WebCams, printing in Silverlight 4.0, etc. However, it is non-trivial. Silverlight 4.0 and Flash both support barcode scanning.
© 2022 - 2024 — McMap. All rights reserved.