DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: IDEA: AutoMaximize Windows  (Read 11,173 times)

Stamimail

  • Participant
  • Joined in 2013
  • *
  • Posts: 23
IDEA: AutoMaximize Windows
« on: April 04, 2013, 12:23 AM »
I've been refused already in other forum...
http://www.classicshell.net/forum/viewtopic.php?f=13&t=391

Still, I think it a great Idea.

Possible?  :Thmbsup:

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: IDEA: AutoMaximize Windows
« Reply #1 on: June 18, 2013, 05:39 PM »
It doesn't seem difficult.  As each window has the focus a tray program could check if the handle is in the list of already processed windows.  If not, get the window attribute.  Check if it has maximize button in frame.  If so, and the current state is not maximized, then max it.

Unfortunately I'm on public library computers for the time beaing.  I can't load any programs let alone programming tools like AHK_L.

A simple Object or associative array with the window handle as the key should be fine for keeping track of windows that have already been maxed.

You could also check a program called WinSize2 to see if it already has the feature.

BigVent

  • Member
  • Joined in 2013
  • **
  • Posts: 36
    • Participated in NANY Challenge Once
Re: IDEA: AutoMaximize Windows
« Reply #2 on: June 19, 2013, 09:10 PM »
*Amended*:

Quote
"would maximize automatically every maximizable window, when new windows of apps/Explorer etc opening."
 
  As I re-read the other linked thread I think this is more suitable for your needs.

Enjoy!


Code: (autohotkey)
;http://www.autohotkey.com/board/topic/19672-detect-when-a-new-window-is-opened/
;DLLCall / Shell / MsgBox = SKAN

;-------------------------------------------------------------------
;--Program monitors newly opened windows & maximizes accordingly--
;-------------------------------------------------------------------

#SingleInstance, force
#Persistent
#NoEnv
SetWorkingDir %A_ScriptDir% 
DetectHiddenWindows, on
onexit, exitsub

Gui +LastFound
hWnd := WinExist()

DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return

ShellMessage( wParam,lParam )
{
  Local k
  If ( wParam = 1 ) ;  HSHELL_WINDOWCREATED := 1
  {
       NewID := lParam
       SetTimer, MsgBox, -1
  }
}

MsgBox:
	 WinGetTitle, Title, ahk_id %NewID%
	 WinGetClass, Class, ahk_id %NewID%
	 WinWait, ahk_id %NewID%
		TrayTip, New Window Opened, Title:`t%Title%`nClass:`t%Class%
	minmax_func()
Return

ralt & Esc::	;right Alt key & Esc
exitsub:
{
    critical
	Exitapp
}

;=================
;==Function(s)====
;=================
minmax_func()
{
	global NewID, minmax
	WinGet, minmax, minmax, ahk_id %NewID%

   if (minmax=0)
   {
      WinMaximize, ahk_id %NewID%
	  ;use PostMessage for stubborn windows
	  ;PostMessage, 0x112, 0xF030,,, NewID  ; 0x112 = WM_SYSCOMMAND, 0xF030 = SC_MAXIMIZE
   }
   else
	if (minmax=-1)
	{
		WinRestore, ahk_id %NewID%
	}
}

~BigVent
~BigVent
« Last Edit: June 20, 2013, 07:33 PM by BigVent »

BigVent

  • Member
  • Joined in 2013
  • **
  • Posts: 36
    • Participated in NANY Challenge Once
Re: IDEA: AutoMaximize Windows
« Reply #3 on: June 20, 2013, 07:53 PM »
Added functionality so that if your program window opens minimized it handles that as well.


~BigVent
~BigVent

Stamimail

  • Participant
  • Joined in 2013
  • *
  • Posts: 23
Re: IDEA: AutoMaximize Windows
« Reply #4 on: April 15, 2015, 11:55 AM »
Hi BigVent,
Sorry for the huge delay... (I didn't get a notification about your reply to my email)
I checked today the script, and it's realy awesome. Very helpful, thank you very much.

There are only few improvments should be done:

1. There are few cases of unwated maximizing, like:
  • When restoring a window from "Minimize to tray", shouldn't be maximized.
  • In opening Properties of file/folder (Alt+Enter).
  • Dialog-box of WinRar extracting.
2. Popup Baloons of icon tray should be removed.

Thank you, Stamimail

BigVent

  • Member
  • Joined in 2013
  • **
  • Posts: 36
    • Participated in NANY Challenge Once
Re: IDEA: AutoMaximize Windows
« Reply #5 on: April 24, 2015, 02:27 PM »
Give this a shot & see what it does for you.


Code: (autohotkey)
;http://www.autohotkey.com/board/topic/19672-detect-when-a-new-window-is-opened/
;DLLCall / Shell / MsgBox = SKAN

;-------------------------------------------------------------------
;--Program monitors newly opened windows & maximizes accordingly--
;-------------------------------------------------------------------

#SingleInstance, force
#Persistent
#NoEnv
SetTitleMatchMode, 2
SetWorkingDir %A_ScriptDir% 
DetectHiddenWindows, on
onexit, exitsub

Gui +LastFound
hWnd := WinExist()

DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return

ShellMessage( wParam,lParam )
{
  Local k
  If ( wParam = 1 ) ;  HSHELL_WINDOWCREATED := 1
  {
       NewID := lParam
       SetTimer, MsgBox, -1
  }
}

MsgBox:
	 WinGetTitle, Title, ahk_id %NewID%
	 WinGetClass, Class, ahk_id %NewID%
	 WinWait, ahk_id %NewID%
				
	;add items you do NOT want maximized here... e.g. Properties Window (Alt+Enter), WinRar, etc.
	;*Note: WinTitles need to be case sensitive 
	if InStr(Title, "Properties") || InStr(Title, "WinRar")
		return
	else
		minmax_func()
Return

ralt & Esc::	;right Alt key & Esc
exitsub:
{
    critical
	Exitapp
}

;=================
;==Function(s)====
;=================
minmax_func()
{
	global NewID, minmax
	WinGet, minmax, minmax, ahk_id %NewID%

   if (minmax=0)
   {
      WinMaximize, ahk_id %NewID%
	  ;use PostMessage for stubborn windows
	  ;PostMessage, 0x112, 0xF030,,, NewID  ; 0x112 = WM_SYSCOMMAND, 0xF030 = SC_MAXIMIZE
   }
   else
	if (minmax=-1)
	{
		WinRestore, ahk_id %NewID%
	}
}
~BigVent

Stamimail

  • Participant
  • Joined in 2013
  • *
  • Posts: 23
Re: IDEA: AutoMaximize Windows
« Reply #6 on: April 25, 2015, 06:09 PM »
It has the same problems as described above (except the popup balloons).

I do not know if it's the right way, but maybe some of the cases can be solved by using: WinKey+UpArrow
« Last Edit: April 25, 2015, 06:14 PM by Stamimail »

Original address: https://www.donationcoder.com/forum/index.php?topic=34533.0