AutoHotkey Community

It is currently May 26th, 2012, 10:36 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: April 30th, 2005, 12:41 pm 
Offline

Joined: April 26th, 2005, 9:32 pm
Posts: 28
Location: Munich, Germany
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 30th, 2005, 1:24 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Nice work. I like how it remembers the original size of each window so that it can be unmaximized later.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Stigg, toddintr and 8 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group