delphi 检测鼠标键盘多久没有活动


本文整理自网络,侵删。

 
delphi 代码
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
//typedef struct tagLASTINPUTINFO {
  //UINT cbSize;
 // DWORD dwTime;
// LASTINPUTINFO, *PLASTINPUTINFO;


type
   LASTINPUTINFO = record
   cbSize:UINT;
   dwTime:DWORD;
end;
var
  Form1: TForm1;

implementation

{$R *.dfm}



function GetInputAwayTime():DWORD;
var
  lpi:TLastInputInfo;
begin
  lpi.cbSize := sizeof(lpi);
  GetLastInputInfo(lpi);
  Result := Round((GetTickCount()-lpi.dwTime)/1000);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
   Caption := IntToStr(GetInputAwayTime)
end;

end.

vc代码
DWORD GetInputAwayTime()
{
  LASTINPUTINFO lpi;
  lpi.cbSize = sizeof(lpi);
  GetLastInputInfo(&lpi);
  return DWORD((GetTickCount()-lpi.dwTime)/1000);
}

相关阅读 >>

Delphi 阿里云发送短信的Delphi单元

Delphi : tstringlist的find,indexof和sort

Delphi 设置combobox组合框的高度方法总结

Delphi中文件名函数-路径、名称、子目录、驱动器、扩展名

Delphi richedit中插入带背景色文本的一种思路

winapi 字符及字符串函数(3): charupper - 字符或字符串转大写

Delphi 如何将颜色值转换为灰度颜色值?

Delphi xe10 针对全面屏手机端无法全面显示,下方显示黑条的处理

Delphi idhttp 获取链接连通状态

Delphi post数据到网页

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...