How to disable the keyboard in C # Windows Form?
Good Guys, I'm facing a problem with my application when I press the ALT key, I'm not expecting any kind of interaction through the keyboard, but even then exclusively this key gives this error
So I do not know why this error, I think it is due to a library that I use to do facial recognition, or because the form that gives error is being called by another form in an incorrect way, I do not know , in order wanted disable the keyboard, as the application in this part does not need the keyboard.
2
1 answers
I use a Windows function, it hangs iteration with the keyboard and mouse as well.
public class Utilidades
{
[DllImport("user32.dll")]
public static extern bool BlockInput(bool Blk);
}
I use it like this:
Utilidades.BlockInput(true); //bloqueia
// codigos
Utilidades.BlockInput(false) // desbloqueia
Add using the following namespace
System.Runtime.InteropServices;