AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Maximize only height/width of a window

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
schandl



Joined: 26 Apr 2005
Posts: 28
Location: Munich, Germany

PostPosted: Sat Apr 30, 2005 11:41 am    Post subject: Maximize only height/width of a window Reply with quote

With some Linux window managers, is possible to maximize only the height or width of a window. That is what the following script does when you press Win+H or Win+W, respectively. When you press it again, the window is resized to its original size.

Since this is my first script, I am happy about all suggestions or improvements.

Bernd
Code:

; ---------------------------------------------------------------------
; Name:        Window Manager Maximize v0.2
; Author:      Bernd Schandl
; Date:        29.04.2005
;
; Explanation:
; ---------------------------------------------------------------------
; The script implements different kinds of maximizing a window similar
; to some Linux window managers:
;  Win-H: Either maximize height or resize it if height was maximized earlier
;  Win-W: Either maximize width or resize it if width was maximized earlier

#h::
  ; get ID, size and position
  WinGet, WM_WindowID, ID, A
  WinGetPos, WM_X, WM_Y, WM_Width, WM_Height, A
  If ( WM_Height <> A_ScreenHeight )
  {
    ; save values for resize
    WM_WindowY%WM_WindowID%      = %WM_Y%
    WM_WindowHeight%WM_WindowID% = %WM_Height%
    ; maximize height
    WinMove, A,, %WM_X%, 0, %WM_Width%, %A_ScreenHeight%
  }
  Else If WM_WindowHeight%WM_WindowID%
  {
    ; height was maximized, so resize it
    WinMove, A, , %WM_X%,  WM_WindowY%WM_WindowID%, %WM_Width%, WM_WindowHeight%WM_WindowID%
    ; reset variables
    WM_WindowHeight%WM_WindowID% =
    WM_WindowY%WM_WindowID%      =
  }
return 

#w::
  ; get ID, size and position
  WinGet, WM_WindowID, ID, A
  WinGetPos, WM_X, WM_Y, WM_Width, WM_Height, A
  If ( WM_Width <> A_ScreenWidth )
  {
    ; save values for resize
    WM_WindowX%WM_WindowID%     = %WM_X%
    WM_WindowWidth%WM_WindowID% = %WM_Width%
    ; maximize width
    WinMove, A,, 0, %WM_Y%, %A_ScreenWidth%, %WM_Height%
  }
  Else If WM_WindowWidth%WM_WindowID%
  {
    ; width was maximized, so resize it
    WinMove, A, , WM_WindowX%WM_WindowID%, %WM_Y%, WM_WindowWidth%WM_WindowID%, %WM_Height%
    ;reset variables
    WM_WindowWidth%WM_WindowID% =
    WM_WindowX%WM_WindowID%     =
  }
return
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Sat Apr 30, 2005 12:24 pm    Post subject: Reply with quote

Nice work. I like how it remembers the original size of each window so that it can be unmaximized later.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group