[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 cursor position at startup
}
Private void timerjavastick (Object sender, system. eventargs E)
{
Byte [] bytcurkeystate = new byte [1, 256];
Getkeyboardstate (ref bytcurkeystate [0]);
For (INT I = 0; I <256; I ++)
{
If (bytcurkeystate [I]> 1) // check whether a keyboard is pressed (including the mouse)
{
Close ();
}
}
Point Pt = new point (0, 0 );
Getcursorpos (ref pt );
If (! PT. Equals (ptold) // check whether the mouse is moved
{
Close ();
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.