标题:WinFrom系统长时间不操作则进行关闭+关闭窗口倒计时
1.首先在界面添加两个timer
2.在窗体运行是开启第一个timer
3.( 0x0202://鼠标左键UP,0x0205://鼠标右键UP,0x0203://鼠标左键双击,case 0x201://鼠标左键Down,case 0x100://键盘按下)
public Form7()
{
InitializeComponent();
MyMessager msg = new MyMessager();
Application.AddMessageFilter(msg);
timer1.Start();
}
static int iOperCount = 0;
static IntPtr hwnd;
static int t;
internal class MyMessager : IMessageFilter
{
public bool PreFilterMessage(ref Message m)
{
//如果检测到有鼠标或则键盘的消息,则使计数为0.....
if (m.Msg == 0x0202 || m.Msg == 0x0205 || m.Msg == 0x0203 || m.Msg == 0x201||
m.Msg == 0x100)
{
iOperCount = 0;
}
return false;
}
}
private void timer1_Tick(object sender, Ev