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

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
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;
 
后退
顶部