2

How to make Inno Setup show a MsgBox after a application is started at the endm when all files are extracted, and make the MsgBox close itself in, lets say, 5 seconds.

And that MsgBox would say something like "Starting World of Tanks Client v0.8.10".

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Jyrka98
  • 530
  • 1
  • 10
  • 19
  • Could you be more specific about "after an application is started at the end when all the files are extracted", please ? Do you want to show that message right after the user presses "Finish" button on the last page before the application starts (if user has checked the "Run application" check box) ? It would be great to make this question general like "Is there a way to show a message box which will automatically close itself after the specified interval ?". I have a (hacky) solution for this, but I don't know from where do you want to call it. – TLama Dec 28 '13 at 15:35
  • This is [`what I meant`](http://stackoverflow.com/q/20816881/960757)... – TLama Dec 28 '13 at 16:47
  • thank you @TLama :-) , but how make this show when a application is started at end? – Jyrka98 Dec 28 '13 at 18:45
  • Well, where to call it I don't know since I was asking for explanation of "after an application is started at the end when all the files are extracted". I'll tell you why, that part "at the end when all the files are extracted" I can understand e.g. as the time when all the items in the `[Files]` section are copied to the target and that you probably want to show that message before the `[Run]` section items are processed (an item can be that application). Or, there is another way I understand your question and it's that you want to show that message when the user presses "Finish" button... – TLama Dec 28 '13 at 23:08
  • ...but then the "when all the files are extracted" part makes not much sense to me. How do you start that application ? From the `[Run]` section ? Or, are we talking about the time when user presses his last "Finish" button to close the wizard ? For me it sounds that the second option is what you want, but you know, "at end" is not an explanation... Give it more time to get help. It's your turn ;-) – TLama Dec 28 '13 at 23:17
  • i meant when the [Run] section is used. the application starts after the setup is done. but how put a (MsbBox) before it starts that program.i dont have it on "postinstall" , so it starts while the Finish page is still shown. @TLama, sorry but i am not very good at explaining :-) – Jyrka98 Dec 28 '13 at 23:38
  • No problem. We are closer to the target... One more thing, you said "after the application is started", but you meant "before it's started", don't you ? Please take into account, that using `MessageBoxTimeout` is blocking, which means that everything stops until the message box is closed. There is a way to start the app with the `nowait` flag which will execute the application and immediately when the execution starts, show the message... But it will lie. The application will already be started when the message will say it's starting... (of course started doesn't mean ready to use) – TLama Dec 29 '13 at 00:13
  • i meant yes, after its started. so it shows "starting..." when the game is loading. but either way is good :-). – Jyrka98 Dec 29 '13 at 00:44
  • I see. It's the message telling the user that a long time app initialization is in progress. If the message box I've used were shown before the application start, it would block that start until the message would be closed, so in fact it would be something like "application will be started after you close this message". And that's not your case, so I've used the first way in my post... – TLama Dec 29 '13 at 02:02

4 Answers4

4

The following script shows how to start an application without waiting for its execution to be finished and immediately after the application is started show a message box for 5 seconds. For this you will need to use the nowait flag for the [Run] section entry, have an AfterInstall function, and a message dialog which is able to close itself after a time period (I have used the one from this post).

The principle is easy; when the [Run] section entry with your application is processed, the application is started and thanks to nowait flag, the entry is taken as processed immediately after the app starts. And since the AfterInstall trigger function is called when the entry is processed, we can show that message dialog from its assigned function:

[Files]
Source: "MyProg.exe"; DestDir: "{app}"

[Run]
Filename: "{app}\MyProg.exe"; AfterInstall: ShowStartingMessageBox; Flags: nowait

[Code]
#ifdef UNICODE
  #define AW "W"
#else
  #define AW "A"
#endif
const
  MB_ICONINFORMATION = $40;

function MessageBoxTimeout(hWnd: HWND; lpText: string; lpCaption: string;
  uType: UINT; wLanguageId: Word; dwMilliseconds: DWORD): Integer;
  external 'MessageBoxTimeout{#AW}@user32.dll stdcall';

procedure ShowStartingMessageBox;
begin
  MessageBoxTimeout(WizardForm.Handle, 'The application is starting... ' +
    'Ok, to be upright; it''s been started, but since its initialization ' +
    'takes a long time, we usually say it''s starting. This message will ' +
    'be automatically closed in 5 seconds!', 'Caption...',
    MB_OK or MB_ICONINFORMATION, 0, 5000);  
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
TLama
  • 75,147
  • 17
  • 214
  • 392
0

That is not possible with Message Box (MsgBox() function) because it stops whole installation process and waits for user interaction.

You need to create

a) a new window which will be shown above installer window and

b) some kind of timer which will show/hide this window after appropriate time.

I think this can be easiier by writing simple C++/C#/Delphi plug-in than writing it in pure Pascal (Inno) code.

Slappy
  • 5,250
  • 1
  • 23
  • 29
0

If you want a more customized implementation than the MessageBoxTimeout from @TLama's answer allows (like a countdown display or custom button captions):

For a complete code, see MsgBox - Make unclickable OK Button and change to countdown - Inno Setup.

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

You could try to use vbscript's shell popup method. The popup should show for 5 seconds ...

[Files]
Source: "MyProg.exe"; DestDir: "{app}"

[Run]
Filename: "{app}\MyProg.exe"; AfterInstall: ShowVBScriptPopup; Flags: nowait

[Code]
procedure ShowVBScriptPopup;
var
  sh;
begin
  sh := CreateOleObject('WScript.Shell');
  sh.Popup('Huhu', 5, 'title');
end;