Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access devices on a client PC from a browser

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).

like image 998
Upperstage Avatar asked Feb 01 '10 18:02

Upperstage


3 Answers

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.

like image 189
T.J. Crowder Avatar answered Sep 20 '22 13:09

T.J. Crowder


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.

like image 43
Pekka Avatar answered Sep 21 '22 13:09

Pekka


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()
like image 39
Mick Avatar answered Sep 18 '22 13:09

Mick