How to disable the keyboard in C # Windows Form?

2

Hi everyone, I'm experiencing 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 this key only gives this error

So I do not know why this error, I think it's 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, keyboard, since the application in this part does not require the keyboard.

    
asked by anonymous 17.11.2015 / 19:52

1 answer

1

I use a Windows function, it locks the iteration with the keyboard and mouse as well.

 public class Utilidades 
 {

   [DllImport("user32.dll")]
   public static extern bool BlockInput(bool Blk);

 }

Use it like this:

Utilidades.BlockInput(true); //bloqueia
// codigos
Utilidades.BlockInput(false) // desbloqueia

add using of the following namespace

  

System.Runtime.InteropServices;

    
18.11.2015 / 17:22