Robert
Robert

Reputation: 6226

Ignore Keyboard Input

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.

Upvotes: 1

Views: 1418

Answers (2)

Robert
Robert

Reputation: 6226

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.

Upvotes: 0

Gil
Gil

Reputation: 138

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.

Upvotes: 1

Related Questions