萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> php編程 >> delphi簡單判斷程序30秒沒有鍵盤和鼠標動作示例

delphi簡單判斷程序30秒沒有鍵盤和鼠標動作示例

本文為大家詳細介紹下delphi判斷程序30秒沒有鍵盤和鼠標動作,這裡給timer設置了1000ms)的參數,表示30秒的間隔,具體實現如下,感興趣的朋友可以參考下哈  

以下為原代碼:
(這裡給timer設置了1000ms)的參數,表示30秒的間隔!!

復制代碼 代碼如下:


unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
procedure AppMessageHandler(var Msg:TMsg;var Handled:Boolean);
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.AppMessageHandler(var Msg: TMsg; var Handled: Boolean);
begin
if (msg.message=WM_MOUSEMOVE) or (msg.message=WM_KEYDOWN) then timer1.tag:=0;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
timer1.tag:=timer1.tag+1;
if Timer1.tag=30 then close;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;
end.

copyright © 萬盛學電腦網 all rights reserved