Skip to content

Instantly share code, notes, and snippets.

@limitedeternity
Last active June 22, 2023 09:49
Show Gist options
  • Save limitedeternity/8c2e6be76f16d74f007433f4c19024ac to your computer and use it in GitHub Desktop.
Save limitedeternity/8c2e6be76f16d74f007433f4c19024ac to your computer and use it in GitHub Desktop.
Supercharged Win+{Up,Down} (AutoHotkey v2)
#Requires AutoHotkey v2.0
#SingleInstance Force
#NoTrayIcon
MINIMIZED := []
STATE_MINIMIZED := -1
return
; Win + Shift + Down = Minimize Window
#+Down::
{
global
for index, winid in MINIMIZED
{
if (!WinExist(winid) || WinGetMinMax(winid) != STATE_MINIMIZED)
{
MINIMIZED.RemoveAt(index)
}
}
if (hwnd := WinExist("A"))
{
winid := "ahk_id " hwnd
if (WinGetMinMax(winid) != STATE_MINIMIZED)
{
PostMessage 0x0112, 0xF020, 0,, winid ; 0x0112 = WM_SYSCOMMAND, 0xF020 = SC_MINIMIZE
MINIMIZED.Push(winid)
}
}
}
; Win + Shift + Up = Restore Window
#+Up::
{
global
for index, winid in MINIMIZED
{
if (!WinExist(winid) || WinGetMinMax(winid) != STATE_MINIMIZED)
{
MINIMIZED.RemoveAt(index)
}
}
if (MINIMIZED.Length)
{
winid := MINIMIZED.Pop()
PostMessage 0x0112, 0xF120, 0,, winid ; 0x0112 = WM_SYSCOMMAND, 0xF120 = SC_RESTORE
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment