Skip to content

Instantly share code, notes, and snippets.

@budRich
Created July 20, 2013 08:24
Show Gist options
  • Save budRich/6044306 to your computer and use it in GitHub Desktop.
Save budRich/6044306 to your computer and use it in GitHub Desktop.
/*
MaxPin
budRich 2013
Pin maximized windows to desktop.
Makes sure only one window is maximized at the same time.
Changes transparency for predefined windows.
*/
#Persistent
; Windows in this list will be transparent when maximized.
MaxTransClass := "Notepad,ConsoleWindowClass"
; Amount of transparency
MaxTrans := 195
; Lets make sure there is no more than one window maximized before we start.
MinimizeMaximized()
SetTimer, ActiveWindowTimer, 500
Return
ActiveWindowTimer:
WinGet, awID, ID, A
WinGetClass, awC, ahk_id %awID%
WinGet, awMaxed , MinMax, ahk_id %awID%
WinGet, mpMaxed , MinMax, ahk_id %MaxPowers%
if (mpMaxed != 1) {
if (MaxPowers != "") {
Sleep, 22
WinGet, mpMaxed , MinMax, ahk_id %MaxPowers%
if (mpMaxed != 1) {
WinSet, Trans, Off, ahk_id %MaxPowers%
MaxPowers := ""
}
}
}
if (awMaxed = 1) {
WinGetClass, mpC, ahk_id %MaxPowers%
WinSet, Bottom,, ahk_id %MaxPowers%
WinSet, AlwaysOnTop, Off, ahk_id %MaxPowers%
if (awID != MaxPowers){
WinSet, AlwaysOnTop, Off, ahk_id %MaxPowers%
if awC in %MaxTransClass%
{
WinSet, Trans, %MaxTrans%, ahk_id %awID%
}
WinMinimize, ahk_id %MaxPowers%
MaxPowers := awID
WinMaximize, ahk_id %nAId%
WinSet, AlwaysOnTop, Off, ahk_id %nAId%
;WinSet, bottom,, ahk_id %nAId%
}
}
return
MinimizeMaximized() {
hw := A_DetectHiddenWindows
rid:=""
DetectHiddenWindows, On
mmchk=0
WinGet, list, list
loop, %list%
{
wid := list%A_Index%
WinGet, es, ExStyle, ahk_id %wid%
WinGet, nAX , MinMax, ahk_id %wid%
; -1: The window is minimized (WinRestore can unminimize it).
; 1: The window is maximized (WinRestore can unmaximize it).
; 0: The window is neither minimized nor maximized.
WinGetClass, ttlMaxChk, ahk_id %wid%
if ((nAX=1) and ! DllCall( "GetWindow", "uint", aId, "uint", GW_OWNER ) and ! ( es & WS_EX_TOOLWINDOW )) or ((nAX=1) and ( es & WS_EX_APPWINDOW ))
{
;~ If ttlMaxChk not in %lstAmc%
mmchk++
if (mmchk>1) {
WinMinimize, ahk_id %wid%
}
rid := wid
}
}
DetectHiddenWindows, %hw%
Return, %rid%
}
@hhs006
Copy link

hhs006 commented Jun 13, 2021

Good

@budRich
Copy link
Author

budRich commented Jun 13, 2021

@hhs006 i had completely forgot i had this script on github. Glad that you like it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment