unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
AppEvnts, ExtCtrls;type
TForm1 = class(TForm)
ApplicationEvents1: TApplicationEvents;
Timer1: TTimer;
procedure ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}
var LastUserActionTime: Cardinal = 0;procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if ((Msg.Message >= WM_KEYFIRST) and (Msg.Message <= WM_KEYLAST)) or
((Msg.Message >= WM_MOUSEFIRST) and (Msg.Message <= WM_MOUSELAST)) then
LastUserActionTime := GetTickCount;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
LastUserActionTime := GetTickCount;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
if GetTickCount - LastUserActionTime > 60 * 1000 then
showmessage('您一分钟没有移动鼠标键盘');
end;end
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
AppEvnts, ExtCtrls;type
TForm1 = class(TForm)
ApplicationEvents1: TApplicationEvents;
Timer1: TTimer;
procedure ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}
var LastUserActionTime: Cardinal = 0;procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if ((Msg.Message >= WM_KEYFIRST) and (Msg.Message <= WM_KEYLAST)) or
((Msg.Message >= WM_MOUSEFIRST) and (Msg.Message <= WM_MOUSELAST)) then
LastUserActionTime := GetTickCount;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
LastUserActionTime := GetTickCount;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
if GetTickCount - LastUserActionTime > 60 * 1000 then
showmessage('您一分钟没有移动鼠标键盘');
end;end
用鼠标在你的form上动,看看效果。
上个帖子我已经发了,里面的idletimer控件也没有调试成功,到底如何解决。钩子不会写,大家能否发个源代码给我!感激不尽![email protected]