开发者

Ignore Keyboard Input

开发者 https://www.devze.com 2023-01-20 05:04 出处:网络
I have an application that displays a keyboard and tests whether the keys have been pressed or not开发者_开发问答.The issue I\'m having is that when certain keys are pressed like the arrow buttons/tab

I have an application that displays a keyboard and tests whether the keys have been pressed or not开发者_开发问答. The issue I'm having is that when certain keys are pressed like the arrow buttons/tab, the keyboard graphic loses focus and it starts accessing menu items/etc. I tried registering to the preview mouse down event in the MainWindow and setting e.handled = true. But this does not work all the time. It would also be nice if there was a way to disable the windows button as well.


I think you would need to get into the operating system code for your solution. The OS treats some keys different from normal, so you may not be able to peak at a key's value or even that it has been pressed before it takes control away from your application.

I saw this kind of thing back when I was writing machine code BIOS routines for CP/M. Windows is much more involved than that. I quit writing code to control hardware when I started to use Windows 3.1.


I used this class:

http://gist.github.com/471698

I replaced line 99 with this code:

return EnableKeyboard ? InterceptKeys.CallNextHookEx(hookId, nCode, wParam, lParam) : (IntPtr) 1;

Where EnableKeyboard is set by the user.

0

精彩评论

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

关注公众号