简体   繁体   中英

Filter specified keyboard device in WPF

I'm writing two C# apps in WPF using MVVM pattern. These apps will be displayed on separate screens. First one is simple app with forms, etc. And another one is phone emulator.

I've bought another keyboard and I want to bind second keyboard device only to phone emulator app, so it doesn't have to work with another applications (web browser, etc.). I'll be good if second app will handle second keyboard events even when focus is on first app.

I've tried to use LowLevelKeyboardProc but I can't find device name/id in given KBDLLHOOKSTRUCT structure.

Do you know some alternative way to do this or how to get device name/id with LowLevelKeyboardProc?

I also had this problem and found this library http://www.oblita.com/interception.html which can be used to intercept keys and know which device they came from. It requires you to install a driver but works very nicely. The only problem for me was that it can't intercept media keys like play, pause, etc. So if you have any other idea i would love to know.

Edit: if you need ac# wrapper there is this one https://github.com/jasonpang/Interceptor

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM