Archive: How to bring the App window to the front


How to bring the App window to the front
When the installation comes to Finish page, I have a check box to Run our App.
The checkbox was checked, then i click on finish button. It dose get App running, but somehow,the window of our App sits behind the other windows.

How can I get our app's window to up front?

James


You can use FindWindow to get your app's HWND and then use an API, such as SetWindowPos to try to bring your app to the front. Note that Windows is restrictive about this at times. You can search the forums for that API to find specific examples with code.
Also, if your installer is one of the windows blocking your app, you can use HideWindow just before you launch it.


can you give me sample code..

Thank you..


Here's an example using SetForegroundWindow, which is probably the better call to use. If you didn't write your app, you can ask the developer or run Spy++ to get the app's window class.

FindWindow $0 "my app's window class" ""
IsWindow $0 0 +2
System::Call 'user32::SetForegroundWindow(i r0)'


where should I put those code? I can get the class name from spy++.
tried to put them into installer, seems to not work...
??


I think those code should be run after I click the finish button, the start our applicaiton, then bring it to up front. Otherwise,it can't find the window since app is not running yet.
???????


Yes, it has to be after your app runs but of course before your installer exits.


so where should I put those code? there is an Event like AfterClickFinishButton?
Thank you for your help.


If you are using MUI, see the MUI documentation for MUI_PAGE_CUSTOMFUNCTION_LEAVE
If not, see the docs for the Page instruction.


Yes, I am using MUI, thanks for your quick reply


But this button is on Finish Page, then run our application .exe file???
still not working


it is not a custom page.


Can you attach your script? It would make it a lot easier to help.


The installer's last page Finish Page.

!define MUI_FINISHPAGE_RUN_TEXT "' Start ${PRODUCT_NAME}'"
!insertmacro MUI_PAGE_FINISH

when installing the installer, after copying files, the comes to last page Finish window. If i click on Finish button on this window, then will run ${PRODUCT_NAME}.exe file. The problem is that ${PRODUCT_NAME}.exe window behind some windows, how can I get it to up front (topmost).
Any thoughts


Try to add the provided by dienjd above code in function .onInstSuccess in loop to see if it makes the trick, e.g.

loop:
FindWindow $0 "my app's window class" ""
IsWindow $0 0 loop
System::Call 'user32::SetForegroundWindow(i r0)'


It does work for me!

Thank you very much, Red Wine.
I always can get answers from you. You are my saver!
Every time when I post my question here, always look forward to hearing from you.


You're welcome :)
Thanks goes to dienjd for the provided solution ;)


Yes. Thanks Dienjd as well.

You guys save me one day work.