[DLLIMPORT ("User32.dll", CallingConvention = CALLINGCONVENTION.STDCALL)]
Private static extern Int getcursorpos (Ref point lppoint);
[DLLIMPORT ("User32.dll", CallingConvention = CALLINGCONVENTION.STDCALL)]
Private static extern int getKeyboardState (Ref byte lpkeystate);
Private point ptold = new point (0,0);
Private Void Form1_Load (Object Sender, System.EventArgs E)
{
GetCursorpos (Ref Ptold); // The location where the mouse is started
}
Private void Timer1_Tick (Object Sender, System.EventArgs E)
{
Byte [] BytcurkeyState = New byte [256];
GetKeyboardState (ref bytcurkeystate;
For (int i = 0; i <256; i )
{
IF (BytcurkeyState [i]> 1) // Check if there is a keyboard being pressed (including mouse)
{
CLOSE ();
}
}
Point Pt = New Point (0, 0);
GetCursorpos (Ref Pt);
If (! pt.equals (ptold)) // check if the mouse moves
{
CLOSE ();
}
}