how to maximize an app just launched using RunProgram

Windows specific forum
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

how to maximize an app just launched using RunProgram

Post 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.
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post 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
-Beach
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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. ;)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post 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! :)
-Beach
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

Sparkie & Beach - thanks alot for your help! :D
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

You're welcome :)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply