开发者

How to convert a USB device button to simulate keyboard button in C#?

I've a digital mike with buttons like play,pause,stop. I can "listen" the events on these buttons by开发者_高级运维 using it's SDK. But I want to use these buttons on a web page.

In my webpage, I can "listen" the multimedia keyboard keys like play,pause, and stop. So I want to map the mike buttons so that pressing the button actually creates an event created by corresponding key on the keyboard.

For example, If I press "pause" button on my USB mike, the keyboard "pause button" event should be triggered. How can I achieve this? and will I have to create a windows service for this?


I'd look into the SendInput function.

Or alternatively the older and simpler keybd_event.

While MS recommends using SendInput, I'd probably use keybd_event because the native interop for it looks a lot easier. To me it looks like the main advantage of SendInput is that it supports multiple inputs within a single call. But you don't need that anyways.


read up on windows hooks.They can be used to simulate keyboard events etc. Most of the code is in c++ but I am sure you can find libraries that provider wrappers for these functions in C#

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜