I'm trying to block input in my program but it doesn't work ...I read about this article and didn't find solution only the problem from vista-7 and above windows... also I found unsolved topic here and I wish from you to help me...
the code from
"mr. LeftTechticle" at youtube video
and he ran it perfectly...
I tried the code but nothing happened...
//------------------------------------------Block Class----------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication14
{
static class InputBlocker
{
[DllImport("user32.dll")]
static extern bool BlockInput(bool fBlockIt);
private static Timer timer = new Timer();
static InputBlocker()
{
timer.Tick += new EventHandler(tick);
}
public static void Block(int mill)
{
BlockInput(true);
timer.Interval = mill;
timer.Start();
}
private static void tick(object sender ,EventArgs e)
{
BlockInput(false);
timer.Stop();
}
}
}
//------------------------------------------Form class---------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication14
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
InputBlocker.Block(10000);
}
}
}