当系统10秒钟内没做任何操作时,系统自动最小化。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
FDelayTime: Integer;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
function LastInput:dword;
var
LInput: TLastInputInfo;
begin
LInput.cbsize := sizeof(TLastInputInfo);
GetLastInputInfo(LInput);
result := GetTickCount - LInput.dwtime;
end;
begin
if FDelayTime <= LastInput then
Self.Perform(WM_SYSCOMMAND, SC_ICON, 0);
//self.WindowState := wsMinimized;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FDelayTime := 10000;
end;
end.