Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Winshade function


  • Please log in to reply
11 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
This script is to reduce windows to their title bars and then set them back to original size by a single hotkey.

works fine.

;Set titlebar settings here 
THeight = 25 
TWidth = 300
;set width above to blank to use original width

#z:: 
   WinGet, ID, ID, A 

   Loop, Parse, WinIDs, |
   { 
      IfEqual, A_LoopField, %ID% 
      { 
         StringTrimRight, Height, %ID%h, 0 
         StringTrimRight, Width, %ID%w, 0 
         WinMove, ahk_id %ID%,,,, %Width%, %height% 
         StringReplace, WinIDs, WinIDs, |%ID% 
         Return 
      } 
   } 

   WinGetActiveStats, Title, Width, Height, X, Y 
   %ID%h = %height% 
   %ID%w = %Width% 
   WinMove, ahk_id %ID%,,,, %TWidth%, %THeight% 
   WinIDs = %WinIDs%|%ID% 
Return 

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
I've posted this script with a minor addition at http://www.autohotke... ... hading.htm

I changed the variable names to make them more unique, which should make it easier to merge into someone's existing/large script without side-effects.

I have quite a few other scripts from this forum I want to post to the showcase (pending). If anyone would like to submit a script, I've posted some basic guidlines here:
http://www.autohotke... ... =3130#3130

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
The embellished version looks great Chris! and thanx for adding it to showcase.
by the way there's a reason i kept '|+|' as the delimiter. its because i've found it in the title of some windows... but what i used is extremely rare. so if there's no specific reason against it then its better be restored.
and yeah the OnExit addition is really nice.

and if one uses a menu entry instead of a hotkey for this function (as i do) then a 'Sleep, 200' must be added as first line of this function, rather its better to add it by default as it doesn't cause a noticeable difference.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

there's a reason i kept '|+|' as the delimiter. its because i've found it in the title of some windows

But I notice you changed it to use the unique ID of each window, not the title, so it should be ok with a single-char delimiter unless I'm missing something.

and if one uses a menu entry instead of a hotkey for this function (as i do) then a 'Sleep, 200' must be added as first line of this function

I added this below the #z definition; hopefully it seems okay:
; Uncomment this next line if this subroutine is to be converted
; into a custom menu item rather than a hotkey. The delay allows
; the active window that was deactivated by the displayed menu to
; become active again:
;Sleep, 200

My reason for commenting it out is that it's conceivable someone could press the hotkey rapidly in succession to hide a series of windows. Due to window animation, the 200ms delay might hinder that ability.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004

But I notice you changed it to use the unique ID of each window, not the title, so it should be ok with a single-char delimiter unless I'm missing something.

err... i was confused. :oops:

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Watcher
  • Members
  • 60 posts
  • Last active: Apr 06 2005 01:57 PM
  • Joined: 27 Dec 2004
Here is a version with animation:

; Window Shading (roll up a window to its title bar) -- by Rajat
; Animation hacks -- by Watcher
; http://www.autohotkey.com
; This script reduces a window to its title bar and then back to its
; original size by pressing a single hotkey.  Any number of windows
; can be reduced in this fashion (the script remembers each).  If the
; script exits for any reason, all "rolled up" windows will be
; automatically restored to their original heights.

; Set the height of a rolled up window here.  The operating system
; probably won't allow the title bar to be hidden regardless of
; how low this number is:
ws_MinHeight = 25
; Should we Animate 1 is yes, 0 is no, animated is slower
ws_Animate = 1
; By What increment (in pixels) does the window roll up, 
; the lower the number the smoother but slower:
ws_RollUpSmoothness = 30
; no sleeping between window operations
SetWinDelay 0

; This line will unroll any rolled up windows if the script exits
; for any reason:
; No animation occurs on exit
OnExit, ExitSub
return  ; End of auto-execute section

#z::  ; Change this line to pick a different hotkey.
; Below this point, no changes should be made unless you want to
; alter the script's basic functionality.
; Uncomment this next line if this subroutine is to be converted
; into a custom menu item rather than a hotkey.  The delay allows
; the active window that was deactivated by the displayed menu to
; become active again:
;Sleep, 200
WinGet, ws_ID, ID, A
Loop, Parse, ws_IDList, |
{
	IfEqual, A_LoopField, %ws_ID%
	{
		; Match found, so this window should be restored (unrolled):
		StringTrimRight, ws_Height, ws_Window%ws_ID%, 0
        if ws_Animate = 1
        {
            ws_RollHeight = %ws_MinHeight%
            Loop
            {
                If ws_RollHeight >= %ws_Height%
                    Break
                ws_RollHeight += %ws_RollUpSmoothness%
                WinMove, ahk_id %ws_ID%,,,,, %ws_RollHeight%
            }
        }
    	WinMove, ahk_id %ws_ID%,,,,, %ws_Height%
		StringReplace, ws_IDList, ws_IDList, |%ws_ID%
		return
	}
}
WinGetPos,,,, ws_Height, A
ws_Window%ws_ID% = %ws_Height%
ws_IDList = %ws_IDList%|%ws_ID%
ws_RollHeight = %ws_Height%
if ws_Animate = 1
{
    Loop
    {
        If ws_RollHeight <= %ws_MinHeight%
            Break
        ws_RollHeight -= %ws_RollUpSmoothness%
        WinMove, ahk_id %ws_ID%,,,,, %ws_RollHeight%
    }
}
WinMove, ahk_id %ws_ID%,,,,, %ws_MinHeight%
return

ExitSub:
Loop, Parse, ws_IDList, |
{
	if A_LoopField =  ; First field in list is normally blank.
		continue      ; So skip it.
	StringTrimRight, ws_Height, ws_Window%A_LoopField%, 0
	WinMove, ahk_id %A_LoopField%,,,,, %ws_Height%
}
ExitApp  ; Must do this for the OnExit subroutine to actually Exit the script.

It's a bit more fun to watch this way.
:shock:

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
i checked it out. looks smoother than mine! :)

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Watcher
  • Members
  • 60 posts
  • Last active: Apr 06 2005 01:57 PM
  • Joined: 27 Dec 2004
It IS yours... just enhanced a little. :D

Dr.Chi
  • Members
  • 3 posts
  • Last active: Apr 05 2005 12:11 PM
  • Joined: 04 Apr 2005
What would I do if I wanted to also reduce the width? Just copy everything and change height to width?

I use a large resolution 1280x1024 (my LCD won't go higher, ugh!) so I not only want the windows to shrink height but also width (so I don't have a super-long title bar hanging out).

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
@Dr.Chi
I've updated the script as per your request.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Dr.Chi
  • Members
  • 3 posts
  • Last active: Apr 05 2005 12:11 PM
  • Joined: 04 Apr 2005
sweeeet.. U the man!

Dr.Chi
  • Members
  • 3 posts
  • Last active: Apr 05 2005 12:11 PM
  • Joined: 04 Apr 2005
hmm...
Hope you don't mind, but after trial and error I changed your code slightly. I wanted to also drop the titlebar "tabs" to the bottom of my screen to get them out of the way till I needed them. It works pretty good, except for the tabs overlapping each other, but oh well.

;Set titlebar settings here 
THeight = 25 
TWidth = 200
TX = 12
TY = 917
;set width above to blank to use original width 

#w:: 
   WinGet, ID, ID, A 

   Loop, Parse, WinIDs, | 
   { 
      IfEqual, A_LoopField, %ID% 
      { 
         StringTrimRight, Height, %ID%h, 0 
         StringTrimRight, Width, %ID%w, 0 
         WinMove, ahk_id %ID%,, %ID%x, %ID%y, %Width%, %height% 
         StringReplace, WinIDs, WinIDs, |%ID% 
         Return 
      } 
   } 

   WinGetActiveStats, Title, Width, Height, X, Y 
   %ID%h = %height% 
   %ID%w = %Width%
   %ID%x = %X%
   %ID%y = %Y% 
   WinMove, ahk_id %ID%,, %TX%, %TY%, %TWidth%, %THeight% 
   WinIDs = %WinIDs%|%ID% 
Return