Right now there's functions to roll/unroll windows, check if the mouse is in the caption, and toggle transparency.
Here's the thing:
;_____Window Management Functions ;_____A couple of useful functions for managing windows, and the variables they need to work ;_____Include this file in your autoexecute section and you're ready to go :) ;_____Initialize variables for window rolling RolledWindowIds = SysGet, CaptionHeight, 4 ;any window you want to ignore rolling, such as a desktop class, put here, seperated by spaces RollExcludeClasses = DesktopBackgroundClass ;_____rolls window under cursor if its unrolled, unrolls if rolled ToggleWindowRoll(hwnd) { global IfInString, RolledWindowIds, ~%hwnd%~ { UnRollWindow(hwnd) } else { RollWindow(hwnd) } } ;_____rolls the window under cursor into its caption RollWindow(hwnd) { global WinGetPos, x, y, width, height, ahk_id %hwnd% if height > 45 { RolledWindowDim%hwnd% = %height% RolledWindowIds := RolledWindowIds . "~" . hwnd . "~" WinMove, ahk_id %hwnd%, , , , ,%captionheight% } } ;_____unrolls the window under cursor UnRollWindow(hwnd) { global StringReplace, RolledWindowIds, RolledWindowIds, ~%hwnd%~ Transform, OldHeight, deref, `%RolledWindowDim%hwnd%`% ;this shouldn't happen, but just in case .... If OldHeight = 0 OldHeight = 400 WinMove, ahk_id %hwnd%, , , , ,%OldHeight% RolledWindowDim%hwnd% = 0 } ;_____unrolls all windows, you should call this in an OnExit sub RestoreWindows() { global RolledWindowIds StringSplit, winid, RolledWindowIds, ~ If winid0 != 0 { Loop, %winid0% { out := winid%A_index% if out != UnRollWindow(winid%A_index%) } } } ;_____returns the id if the mouse is in the caption area of the window, excluding icon area, and certain classes IsInCaption() { global CaptionHeight, RollExclude Classes MouseGetPos, x, y, id WinGetClass, class, Ahk_id %id% WinGetPos, winx, winy, winw, winh, ahk_id %id% If (x > (20 + winx)) && (x < (winx + winw)) && (y < (CaptionHeight + winy)) && (y > (winy)) && (InString(RollExcludeClasses,class) != 1) return id else return 0 } ;____function version of ifinstring InString(lookin, lookfor) { IfInString, lookin, lookfor return 1 else return 0 } ;_____Toggles 150 transparency on/off ToggleActiveTransparency() { Winget, trans, transparent, A if trans = 150 Winset, transparent, OFF, A else Winset, transparent, 150, A }
And here's an example on how it's meant to be used
You can roll up a window by right-clicking on the caption, and toggle its transparency by middle clicking there.
#include windowfunctions.ahk OnExit, ext ;_____Roll Window RButton:: r_id := IsInCaption() If r_id = 0 MouseClick, r else ToggleWindowRoll(r_id) return #r:: MouseGetPos, , , r_id ToggleWindowRoll(r_id) return ;_____Transparency Toggle MButton:: r_id := IsInCaption() If r_id = 0 MouseClick, m else ToggleActiveTransparency() return #!t:: ToggleActiveTransparency() return exit: RestoreWindows() return
I noticed occasional Wacky Behaviorâ„¢, so please let me know if you encounter it so that it can be fixed. So far I've had problems pinning down the cause.