unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Vcl.ExtCtrls;
type
TForm1 =
class(TForm)
Timer1: TTimer;
Button1: TButton;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure SetCursorToControl(Control: TControl);
var P: TPoint;
begin
P.X := Control.Width
div 2;
P.Y := Control.Height
div 2;
P := Control.ClientToScreen(P);
SetCursorPos(P.X, P.Y);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Timer1.Enabled:= TRUE;
Button1.Enabled:= FALSE;
Self.WindowState:= wsMinimized;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
// interval:= 10000;
begin
Timer1.Enabled:= FALSE;
Button1.Enabled:= TRUE;
Application.BringToFront;
//Setzt das zuletzt aktive Fenster auf dem Desktop in den Vordergrund
Self.WindowState:= wsNormal;
// besser als: Application.Restore;
SetCursorToControl(self);
mouse_event(MOUSEEVENTF_LEFTDOWN, 50, 50, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 50, 50, 0, 0);
end;
end.