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);
}

相关阅读 >>

Delphixe firemonkey 如何画图

Delphi xe8 支持md5

Delphi xe5 实现获取本地的ip地址

Delphi压缩库 zlibex 介绍

Delphi 三种方式读取txt文本文件

Delphi android 安卓中保持屏幕常亮

Delphi窗口显示于parent控件上

Delphi 自定义colorbox只显示指定颜色项目 colorbox显示中文颜色名称

Delphi webbrowser1 读取当前页面字体大小

Delphi -- 农历算法单元

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



打赏

取消

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

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

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

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

评论

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