it is very easy , use for each for all of the controls in your form and put the enable=false. use a timer in your program that stores mouse location.and compare 7 state of your mouse in a time range like 20 seconds and if the state is not changed make all of the enable of all of controls to false. need more help? comment.
int Current_Key=0;
stMouseLoc[] mouseloc = new stMouseLoc[20];
int mouse_Currentposition_X;
int mouse_Currentposition_Y;
private void timer1_Tick(object sender, EventArgs e)
{
stMouseLoc currentmouseloc = new stMouseLoc();
currentmouseloc.x = mouse_Currentposition_X;
currentmouseloc.y = mouse_Currentposition_Y;
currentmouseloc.key = Current_Key;
mouseloc[Current_Key] = currentmouseloc;
Current_Key++;
bool movement = false;
if (Current_Key == 20)
{
for (int i = 1; i < 20; i++)
{
if (mouseloc[0].x != mouseloc[i].x || mouseloc[0].x != mouseloc[i].x)
{
movement = true;
}
}
if (!movement) fncFreeze();
Current_Key = 0;
}
}
public void fncFreeze()
{
foreach (Control X in this.Controls)
{
X.Enabled= false;
}
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
mouse_Currentposition_X = e.X;
mouse_Currentposition_Y = e.Y;
}
use array of a struct like this:
public struct stMouseLoc
{
public int x;
public int y;
public int key;
}
put timer1.interval=1000; //1second