View Full Version : Bring Suite Window to Front

12-30-2015, 04:02 PM
My Suite Window is often hidden behind other windows. How do I bring it to the front? I tried an InstallScript event.

export prototype SetWindowFocus(OBJECT);
function SetWindowFocus(oTest)
HWND hMain;
hMain = GetWindowHandle( HWND_INSTALL );
SetForegroundWindow( hMain );

I know it is getting executed because if I put it in 'OnBegin' (illegal because there is no UI yet) it exits the install. If I put it in OnStaging or later it seemingly does nothing.

OK.. it seems like the proper place for it to be scheduled is as a 'Page Entered Event' on the InstallWelcome page (at least for a first install). So it is executing in the proper place according to the log. Now to make it the above script actually work :(

Thanks for any ideas!

01-19-2016, 10:16 PM
Kicking this to the top of the pile.

What is causing the Suite window to be in the background is that I launch a bat file in OnBegin to check versions of 3rd party apps, SQL instances, etc and log info about all of that. In the bat I PAUSE if there are any items that I need to warn the user about. So if I PAUSE, the Suite window remains in the background even after closing the bat file. If I do not PAUSE the Suite window is in the foreground. Anybody have any ideas?


01-28-2016, 11:32 AM
Thanks to Phil at Flexera Support I have this working using the InstallScript code below.
I then created a Events Action named SetWindowFocus and run that action as a 'Page Entered' event on the appropriate Wizard Page.
Thanks Phil!

export prototype SetWindowFocus(OBJECT);

prototype USER.AttachThreadInput( HWND, LONG, BOOL );
prototype USER.GetWindowThreadProcessId( HWND, LONG );
prototype KERNEL.GetCurrentThreadId();
prototype HWND USER.GetForegroundWindow();

function SetWindowFocus(oExtension)
HWND hMain;

hMain = FindWindow("#32770", "");
if (hMain != NULL) then
SendMessage (hMain, WM_SYSCOMMAND, SC_RESTORE, 0);

//Attach foreground window thread to installation thread
AttachThreadInput( GetWindowThreadProcessId( GetForegroundWindow(), NULL ), GetCurrentThreadId(), TRUE );

//Bring to foreground
SetWindowPos( hMain, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
SetForegroundWindow( hMain );

//Detach the attached thread
AttachThreadInput( GetWindowThreadProcessId( GetForegroundWindow(), NULL ), GetCurrentThreadId(), FALSE );
SetFocus( hMain );

01-29-2016, 07:51 AM
Thank you for sharing !



01-29-2016, 11:26 AM
Thank you for sharing !

Seconded! Useful bit of code to keep in your backpocket. Thank you.

09-28-2016, 03:57 AM
It is working as expected and Thanks a lot for this code :)