Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 11, 2016, 01:55:26 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: AutoMaximize Windows  (Read 3984 times)

Stamimail

  • Participant
  • Joined in 2013
  • *
  • default avatar
  • Posts: 15
    • View Profile
    • Donate to Member
IDEA: AutoMaximize Windows
« on: April 03, 2013, 07:23:51 PM »
I've been refused already in other forum...
http://www.classicsh...c.php?f=13&t=391

Still, I think it a great Idea.

Possible?  :Thmbsup:

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,290
    • View Profile
    • Miles Ahead Software
    • Donate to Member
Re: IDEA: AutoMaximize Windows
« Reply #1 on: June 18, 2013, 12:39:00 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
    • View Profile
    • Donate to Member
Re: IDEA: AutoMaximize Windows
« Reply #2 on: June 19, 2013, 04:10:45 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 [Select]
  1. ;http://www.autohotkey.com/board/topic/19672-detect-when-a-new-window-is-opened/
  2. ;DLLCall / Shell / MsgBox = SKAN
  3.  
  4. ;-------------------------------------------------------------------
  5. ;--Program monitors newly opened windows & maximizes accordingly--
  6. ;-------------------------------------------------------------------
  7.  
  8. SetWorkingDir %A_ScriptDir%
  9. onexit, exitsub
  10.  
  11. Gui +LastFound
  12. hWnd := WinExist()
  13.  
  14. DllCall( "RegisterShellHookWindow", UInt,hWnd )
  15. MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
  16. OnMessage( MsgNum, "ShellMessage" )
  17. Return
  18.  
  19. ShellMessage( wParam,lParam )
  20. {
  21.   Local k
  22.   If ( wParam = 1 ) ;  HSHELL_WINDOWCREATED := 1
  23.   {
  24.        NewID := lParam
  25.        SetTimer, MsgBox, -1
  26.   }
  27. }
  28.  
  29.          WinGetTitle, Title, ahk_id %NewID%
  30.          WinGetClass, Class, ahk_id %NewID%
  31.          WinWait, ahk_id %NewID%
  32.                 TrayTip, New Window Opened, Title:`t%Title%`nClass:`t%Class%
  33.         minmax_func()
  34. Return
  35.  
  36. ralt & Esc::    ;right Alt key & Esc
  37. exitsub:
  38. {
  39.     critical
  40.         Exitapp
  41. }
  42.  
  43. ;=================
  44. ;==Function(s)====
  45. ;=================
  46. minmax_func()
  47. {
  48.         global NewID, minmax
  49.         WinGet, minmax, minmax, ahk_id %NewID%
  50.  
  51.    if (minmax=0)
  52.    {
  53.       WinMaximize, ahk_id %NewID%
  54.           ;use PostMessage for stubborn windows
  55.           ;PostMessage, 0x112, 0xF030,,, NewID  ; 0x112 = WM_SYSCOMMAND, 0xF030 = SC_MAXIMIZE
  56.    }
  57.    else
  58.         if (minmax=-1)
  59.         {
  60.                 WinRestore, ahk_id %NewID%
  61.         }
  62. }

~BigVent
~BigVent
« Last Edit: June 20, 2013, 02:33:18 PM by BigVent, Reason: Removed the other application as it was not needed. »

BigVent

  • Member
  • Joined in 2013
  • **
  • Posts: 36
    • View Profile
    • Donate to Member
Re: IDEA: AutoMaximize Windows
« Reply #3 on: June 20, 2013, 02:53:46 PM »
Added functionality so that if your program window opens minimized it handles that as well.


~BigVent
~BigVent

Stamimail

  • Participant
  • Joined in 2013
  • *
  • default avatar
  • Posts: 15
    • View Profile
    • Donate to Member
Re: IDEA: AutoMaximize Windows
« Reply #4 on: April 15, 2015, 06:55:00 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
    • View Profile
    • Donate to Member
Re: IDEA: AutoMaximize Windows
« Reply #5 on: April 24, 2015, 09:27:16 AM »
Give this a shot & see what it does for you.


Code: Autohotkey [Select]
  1. ;http://www.autohotkey.com/board/topic/19672-detect-when-a-new-window-is-opened/
  2. ;DLLCall / Shell / MsgBox = SKAN
  3.  
  4. ;-------------------------------------------------------------------
  5. ;--Program monitors newly opened windows & maximizes accordingly--
  6. ;-------------------------------------------------------------------
  7.  
  8. SetWorkingDir %A_ScriptDir%
  9. onexit, exitsub
  10.  
  11. Gui +LastFound
  12. hWnd := WinExist()
  13.  
  14. DllCall( "RegisterShellHookWindow", UInt,hWnd )
  15. MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
  16. OnMessage( MsgNum, "ShellMessage" )
  17. Return
  18.  
  19. ShellMessage( wParam,lParam )
  20. {
  21.   Local k
  22.   If ( wParam = 1 ) ;  HSHELL_WINDOWCREATED := 1
  23.   {
  24.        NewID := lParam
  25.        SetTimer, MsgBox, -1
  26.   }
  27. }
  28.  
  29.          WinGetTitle, Title, ahk_id %NewID%
  30.          WinGetClass, Class, ahk_id %NewID%
  31.          WinWait, ahk_id %NewID%
  32.                                
  33.         ;add items you do NOT want maximized here... e.g. Properties Window (Alt+Enter), WinRar, etc.
  34.         ;*Note: WinTitles need to be case sensitive
  35.         if InStr(Title, "Properties") || InStr(Title, "WinRar")
  36.                 return
  37.         else
  38.                 minmax_func()
  39. Return
  40.  
  41. ralt & Esc::    ;right Alt key & Esc
  42. exitsub:
  43. {
  44.     critical
  45.         Exitapp
  46. }
  47.  
  48. ;=================
  49. ;==Function(s)====
  50. ;=================
  51. minmax_func()
  52. {
  53.         global NewID, minmax
  54.         WinGet, minmax, minmax, ahk_id %NewID%
  55.  
  56.    if (minmax=0)
  57.    {
  58.       WinMaximize, ahk_id %NewID%
  59.           ;use PostMessage for stubborn windows
  60.           ;PostMessage, 0x112, 0xF030,,, NewID  ; 0x112 = WM_SYSCOMMAND, 0xF030 = SC_MAXIMIZE
  61.    }
  62.    else
  63.         if (minmax=-1)
  64.         {
  65.                 WinRestore, ahk_id %NewID%
  66.         }
  67. }
~BigVent

Stamimail

  • Participant
  • Joined in 2013
  • *
  • default avatar
  • Posts: 15
    • View Profile
    • Donate to Member
Re: IDEA: AutoMaximize Windows
« Reply #6 on: April 25, 2015, 01:09:13 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, 01:14:56 PM by Stamimail »