首页  编辑  

监测程序多久没有用户输入

Tags: /超级猛料/Alogrith.算法和数据结构/杂项/   Date Created:

]、。·ˉˇ¨〃々—~‖…’”〕〉》」』〗】∶!"'),.:;?]` const TimeOut=600000;

procedure TForm1.FormCreate(Sender: TObject);

begin

 Timer1.Interval :=TimeOut;

 Start:=GetTickCount;

 Application.OnMessage :=MyMessage;

end;

procedure TForm1.MyMessage(var Msg: TMsg;var Handled: Boolean);

begin

 case Msg.message of

   WM_MouseMove      :Start:=GetTickCount;

   WM_LBUTTONDOWN    :Start:=GetTickCount;

   WM_RBUTTONDOWN    :Start:=GetTickCount;

   //WM_MOUSEWHEEL      :Start:=GetTickCount;

   WM_KeyDown        :Start:=GetTickCount;

   WM_Char            :Start:=GetTickCount;

 end;

end;

procedure TForm1.Timer1Timer(Sender: TObject);

begin

 if GetTickCount-Start>=TimeOut then

 begin

   Start:=GetTickCount;

   Application.Minimize;

 end;

end;