Usuário com melhor resposta
Como desabilitar o teclado e mouse

Pergunta
-
Respostas
-
Olá Henrique,
Acho que encontrei exatamente o que você precisa:
public partial class NativeMethods { /// Return Type: BOOL->int ///fBlockIt: BOOL->int [System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint="BlockInput")] [return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] public static extern bool BlockInput([System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool fBlockIt) ; } public static void BlockInput(TimeSpan span) { try { NativeMethods.BlockInput(true); Thread.Sleep(span); } finally { NativeMethods.BlockInput(false); } }
Chame o método BlockInput informando um objeto do tipo TimeSpan com o tempo que você deseja que o mouse e o teclado sejam bloqueados.
Fonte: How can I block keyboard and mouse input in C#?
Herbert Lausmann
- Sugerido como Resposta Herbert Lausmann quinta-feira, 13 de fevereiro de 2014 20:29
- Marcado como Resposta Giovani Cr sexta-feira, 14 de fevereiro de 2014 11:29
-
Boa Tarde...
[DllImport("user32.dll")] private static extern bool BlockInput(bool fBlockIt); public static void TravarTeclado(bool Acao) { BlockInput(Acao); }
- Marcado como Resposta Giovani Cr sexta-feira, 14 de fevereiro de 2014 11:29
Todas as Respostas
-
Olá Henrique,
Acho que encontrei exatamente o que você precisa:
public partial class NativeMethods { /// Return Type: BOOL->int ///fBlockIt: BOOL->int [System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint="BlockInput")] [return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] public static extern bool BlockInput([System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool fBlockIt) ; } public static void BlockInput(TimeSpan span) { try { NativeMethods.BlockInput(true); Thread.Sleep(span); } finally { NativeMethods.BlockInput(false); } }
Chame o método BlockInput informando um objeto do tipo TimeSpan com o tempo que você deseja que o mouse e o teclado sejam bloqueados.
Fonte: How can I block keyboard and mouse input in C#?
Herbert Lausmann
- Sugerido como Resposta Herbert Lausmann quinta-feira, 13 de fevereiro de 2014 20:29
- Marcado como Resposta Giovani Cr sexta-feira, 14 de fevereiro de 2014 11:29
-
Boa Tarde...
[DllImport("user32.dll")] private static extern bool BlockInput(bool fBlockIt); public static void TravarTeclado(bool Acao) { BlockInput(Acao); }
- Marcado como Resposta Giovani Cr sexta-feira, 14 de fevereiro de 2014 11:29