您的位置:首页 > 其它

检测用户超过5分钟没有操作键盘或鼠标+函数

2012-10-29 11:23 281 查看
1.>>>5秒后提示,但只有一次============================================

procedure TForm1.Timer1Timer(Sender: TObject);
var  vLastInputInfo: TLastInputInfo;
begin
vLastInputInfo.cbSize := SizeOf(vLastInputInfo);
GetLastInputInfo(vLastInputInfo);
if GetTickCount - vLastInputInfo.dwTime > 5000 then
begin
timer1.Enabled:= false;
showmessage('超过5秒,用户未动鼠标!');
end;
end;

得到停止操作时间

1. 定义过程

function LastInput: DWord;

2.解释过程

function TForm1.LastInput: DWord;
var
LInput: TLastInputInfo;
begin
LInput.cbSize := SizeOf(TLastInputInfo);
GetLastInputInfo(LInput);
Result := GetTickCount - LInput.dwTime;
end;

3.使用函数

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Caption:=IntToStr(LastInput);
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: