public Form1()
{
InitializeComponent();
MyMessager msg = new MyMessager();
Application.AddMessageFilter(msg);
timer1.Start();
}
static int iOperCount = 0;
internal class MyMessager : IMessageFilter
{
public bool PreFilterMessage(ref Message m)
{
//如果检测到有鼠标或则键盘的消息,则使计数为0.....
if (m.Msg == 0x0200 || m.Msg == 0x0201 || m.Msg == 0x0204 || m.Msg == 0x0207)
{
iOperCount = 0;
}
return false;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
iOperCount++;
if (iOperCount > 100)
{
Application.Exit();
}
}
评论记录:
回复评论: