RSS订阅 | 匿名投稿
您的位置:网站首页 > 鼠标 > 正文

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

作者:admin 来源: 日期:2013/11/25 20:35:20 人气: 标签:

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


读完这篇文章后,您心情如何?
0
0
0
0
0
0
0
0
本文网址: