Hello, as all my searches have come up dry, and I've gotten a bit rusty with c# in the last couple months, I decided to ask this here.
Basically I need to catch any and all key presses (shift, alt, control, Letters, Numbers, as well as other function keys on a keyboard) record and suppress them before they get to whatever application is currently in the forground while the variable is set to true. Basically one key on the keyboard will toggle the variable between true and false, but the real issue is Getting the key presses and suppressing them. I know KeyEventArgs and SuppressKeyPress come into play, but due to the nature of what I need, the majority of the details on it have been hidden. Any assistance would be greatly appreciated.
Loading
Jan MontanoPosted Mar 4, 2009, 12:30 AM
Here's another example from codeproject.
Jan MontanoPosted Mar 5, 2009, 1:01 AM
AlexPosted Mar 4, 2009, 12:50 PM
There are 2 reasons I want this - 1) It would make the code a hell of alot more efficient, and 2) I dont know what the computer currently detects that key as when it is pressed. There is an incredibly long list of keys, and I am certain it is one of them, so do I have to enter the entire list as hooked keys, or is there an easier way? :)
AlexPosted Mar 3, 2009, 6:39 PM
I thought I described what I needed, although I have been known to be quite confusing in the past, so heres attempt number 2. :)
This is a very small part of a larger program, but is also a required part to make it work fully. Explaining the full program would be lengthy and would just confuse me more, so I am less likely to confuse you along with myself. :)
What I need is:
I need the program to watch all keypresses on the keyboard - while not being the focused application, simply running in the background - and if a specific key is pressed, it begins copying every key that is pressed and suppressing them before they can get to the application that is in the forground, until the key is pressed again.
The problem is:
1) Reading the Keystrokes when not in focus - and I mean all keystrokes, numbers, letters, as well as other buttons on the keyboard
and 2) Suppressing Keystrokes.
I have found code relating to both of these in the past, but no matter what I tried, they always gave syntax errors. As they were always very short bits of code, I assume that it would be easier to get an answer rather than try and troubleshoot the mistakes I make with those blocks.
govindan logeshPosted Mar 3, 2009, 11:31 AM