Я хочу на короткое время заблокировать ввод с клавиатуры пользователя, но метод не работает.
открытый частичный класс NativeMethods {
[DllImport("user32.dll", EntryPoint = "BlockInput")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool BlockInput([MarshalAs(UnmanagedType.Bool)] bool fBlockIt);
}
public class KeyboardBlocker
{
public static void Block(int span)
{
try
{
NativeMethods.BlockInput(true);
Console.WriteLine("should have blocked");
Thread.Sleep(span);
}
finally
{
NativeMethods.BlockInput(false);
у кого-нибудь есть идея?Спасибо уже