热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

筛选WPF中指定的键盘设备-FilterspecifiedkeyboarddeviceinWPF

ImwritingtwoC#appsinWPFusingMVVMpattern.Theseappswillbedisplayedonseparatescreens.

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.

我正在使用MVVM模式在WPF中编写两个c#应用程序。这些应用程序将分别显示在不同的屏幕上。一种是简单的带有表单的app,另一种是手机模拟器。

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.

我买了另一个键盘,我想把第二个键盘设备绑定到手机模拟器应用上,这样它就不需要和其他应用程序(web浏览器等)一起工作了。如果第二个应用能处理第二个键盘事件,即使焦点在第一个应用上,我也会很好。

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

我尝试过使用低级别keyboardproc,但是在给定的KBDLLHOOKSTRUCT结构中找不到设备名/id。

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

你知道有什么替代方法吗?或者你知道如何用LowLevelKeyboardProc获取设备名/id吗?

1 个解决方案

#1


0  

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.

我也遇到了这个问题,找到了这个库http://www.ta.com/interception.html,它可以用来截获密钥,并知道它们来自哪个设备。它需要你安装一个驱动程序,但是工作得很好。对我来说,唯一的问题是它不能拦截媒体键,比如播放、暂停等等。所以如果你有其他想法,我很想知道。

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

编辑:如果需要一个c#包装器,就会有一个https://github.com/jasonpang/Interceptor。


推荐阅读
author-avatar
李金铃519
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有