开发者

Is that possible to provide a JavaScript API to control USB, LPT, and COM devices?

开发者 https://www.devze.com 2023-01-26 00:55 出处:网络
I have a computer running Windows and connected with many devices, such as a printer, an RFID reader, etc.

I have a computer running Windows and connected with many devices, such as a printer, an RFID reader, etc.

I want all my applications run as HTML, CSS, and JavaScript, so I need to acce开发者_StackOverflow中文版ss these devices through JavaScript. But I don't know if it is possible to add custom JavaScript API to browser (such as Internet Explorer or Firefox), or what work are needed to make this possible.


You can use a browser's basic printing abilities to control a printer and may be able to find a keyboard wedge RFID reader, both of which would allow you to use just basic JavaScript code to operate them. However, you more than likely will need an ActiveX control (COM component) that you can instantiate from a browser script to be able to have any real control over the devices.

Unfortunately, you may have to write those controls yourself. You might be able to do it in C# with some judicious use of P/Invoke, however.


Another possibility is to write a browser plug-in that would act as a helper. I believe browser plug-ins, such as ones for Firefox, have more free reign access to your physical machine. It could accept commands from your website to be executed outside of the browser's JavaScript sandbox. Also I believe you can write browser plug-ins for Firefox in JavaScript.

0

精彩评论

暂无评论...
验证码 换一张
取 消