Open application on top of web page with Inno Setup

96 Views Asked by At

When user clicks on Finish button, a webpage will open along with the software exe. But the issue is that the web page will always remain on top.

In Run section:

Filename: "{app}\abc.exe"; Description: {cm:LaunchProgram,ABC}; \
  Flags: nowait postinstall skipifsilent shellexec runasoriginaluser runmaximized; \
  WorkingDir: {app}

Requirement is that the exe needs to be on top.

The code I followed to open a webpage:

const insSiteURLEN = 'https://example.com';

procedure CurStepChanged(CurStep: TSetupStep); 
var ErrorCode: Integer;
begin 
  if CurStep=ssDone then 
  begin 
    ShellExec('', insSiteURLEN, '', '', SW_SHOW, ewNoWait, ErrorCode); 
  end; 
end; 
1

There are 1 best solutions below

0
Martin Prikryl On

I'm afraid it is hard to achieve. You are starting two applications in parallel. The one that manages to open its window first will get overshadowed by the one that takes longer to open.

You are definitely not helping it by opening the webpage later than the application – CurStepChanged(ssDone) is triggered after running the postinstall Run entries. Move the web page opening code to the NextButtonClick(wpFinished).

Though even that will not guarantee that the application opens on the top of the browser. It just makes it more likely.

Btw, it would be even more easy to implement, if you open the webpage via Run. That would even allow the user to decide if s/he want to open the webpage at all.