Page 1 of 1

how to maximize an app just launched using RunProgram

Posted: Tue Feb 28, 2006 3:44 am
by mskuma
Hi

I'm building a launcher app - uses buttons to open Internet Explorer & other apps. I'm using RunProgram to launch these apps. I want to launch any app as maximized from the outset. Seems like there is no RunProgram switch to launch as maximized. So for IE, I am doing the following - but surely there is a better way? and of course this is IE specific. I'd like to be able to maximize any app that I launch this way.

Code: Select all

Procedure MaximizeIE()

  h.l = GetTopWindow_(0) 
  
  While h <> 0 
  
    name.s = Space(513) 
    GetWindowText_(h,@name,512) 
  
    If FindString(name,"Internet Explorer",0)
      Debug "name = " + name
      ShowWindow_(h,#SW_SHOWMAXIMIZED)
    EndIf
    ; 
    h = GetWindow_(h,#GW_HWNDNEXT) 
    
  Wend 

EndProcedure

RunProgram("http://www.google.com/")
MaximizeIE()
Thanks to blueznl et al from this topic - that gave me the tip
viewtopic.php?t=18494

Thanks very much for any suggestion.

Posted: Tue Feb 28, 2006 4:39 am
by Beach
While we wait for Sparkie to lay down the richeous code (just joking Sparkie!!)... You could use the AutoIT lib or the DLL in your app. The example below is for IE but could be used for any app:

Code: Select all

RunProgram("iexplore","http://www.purebasic.com","")
AU3_AutoItSetOption_("WinTitleMatchMode",2) ;match any substring in the title
AU3_WinWaitActive_("Microsoft Internet Explorer","",5) ;wait for the ie window to appear
AU3_WinSetState_("Microsoft Internet Explorer","",#SW_MAXIMIZE) ;maximize window

Posted: Tue Feb 28, 2006 4:47 am
by Sparkie
Noth'n like put'n the pressure on me Beach :P :)

I swear I saw some other code around here for that purpose. I'll see if I can find it. ;)

Posted: Tue Feb 28, 2006 4:49 am
by Beach
Or you could change the procedure around a little to make it work without AutoIT.

Code: Select all

Procedure MaximizeApp(AppTitle$)
  
  h.l = GetTopWindow_(0)
  
  While h <> 0
    
    name.s = Space(512)
    GetWindowText_(h,@name,512)
    
    If FindString(name,AppTitle$,0) 
      ShowWindow_(h,#SW_SHOWMAXIMIZED)
    EndIf
    ;
    h = GetWindow_(h,#GW_HWNDNEXT)
    
  Wend
  
EndProcedure

RunProgram("notepad")
Delay(500)
MaximizeApp("Notepad")
@Sparkie

You-da-man Sparkie, you know I got nothing but respect here! :)

Posted: Tue Feb 28, 2006 5:07 am
by Sparkie
I've seen you create some magic as well Beach :) If I ever get into Linux, you'll be hearing from me. ;)


@mskuma: Take a look at the ShellExecute Function...
http://msdn.microsoft.com/library/defau ... xecute.asp

Code: Select all

ShellExecute_(#Null, @"open", @"IExplore.exe", #Null, #Null, #SW_MAXIMIZE)

Posted: Tue Feb 28, 2006 5:24 am
by mskuma
Sparkie & Beach - thanks alot for your help! :D

Posted: Tue Feb 28, 2006 5:29 am
by Sparkie
You're welcome :)