cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
rguggisberg
Level 13

Bring Suite Window to Front

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;
begin
hMain = GetWindowHandle( HWND_INSTALL );
SetForegroundWindow( hMain );
end;

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!
Labels (1)
0 Kudos
(5) Replies
rguggisberg
Level 13

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?

Thanks
0 Kudos
rguggisberg
Level 13

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;

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

//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 );
end;
///////////////////////////////////////////////////////////////////////////////
0 Kudos
MarkusLatz
Level 8

Thank you for sharing !

regards

Markus
0 Kudos
Not applicable

MarkusLatz wrote:
Thank you for sharing !


Seconded! Useful bit of code to keep in your backpocket. Thank you.
0 Kudos
srikanth_suguma
Level 2

It is working as expected and Thanks a lot for this code 🙂
0 Kudos