4

How to close the installer on the "Finished" page after a certain time?

It could also be interpreted as: how to close the installer after some time of non-activity? (close/cancel install). Is this possible?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Nico Z
  • 997
  • 10
  • 33

1 Answers1

5

Setup a timer once the "Finished" page displays to trigger the close.

[Code]

function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): LongWord;
  external 'SetTimer@User32.dll stdcall';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord;
  external 'KillTimer@User32.dll stdcall';

var
  PageTimeoutTimer: LongWord;
  PageTimeout: Integer;

procedure UpdateFinishButton;
begin
  WizardForm.NextButton.Caption :=
    Format(SetupMessage(msgButtonFinish) + ' - %ds', [PageTimeout]);
end;  

procedure PageTimeoutProc(
  H: LongWord; Msg: LongWord; IdEvent: LongWord; Time: LongWord);
begin
  if PageTimeout > 1 then
  begin
    Dec(PageTimeout);
    UpdateFinishButton;
  end
    else
  begin
    WizardForm.NextButton.OnClick(WizardForm.NextButton);
  end;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpFinished then
  begin
    PageTimeout := 10;
    UpdateFinishButton;
    PageTimeoutTimer := SetTimer(0, 0, 1000, CreateCallback(@PageTimeoutProc));
  end;
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if CurPageID = wpFinished then
  begin
    KillTimer(0, PageTimeoutTimer);
    PageTimeoutTimer := 0;
  end;
  Result := True;
end;

Timeout of Finished page

For CreateCallback function, you need Inno Setup 6. If you are stuck with Inno Setup 5, you can use WrapCallback function from InnoTools InnoCallback library.


Related questions:

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992