💾 Archived View for tdem.in › post › autohotkey-better-minimize.gmi captured on 2023-04-19 at 22:32:49. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-06-03)

-=-=-=-=-=-=-

Back to blog

AutoHotkey: Scratchpad

2019-06-10 01:28

Another day, another hack. This AutoHotkey snippet preserves the last window you minimized with `Win + Down` and allows you to quickly unminimize it with `Win + Shift + Up`:

AutoHotkey

global lastWindow
ToScratchpad()
{
    WinGetTitle, lastWindow, A
    WinMinimize, %lastWindow%
}
FromScratchpad()
{
    WinActivate, %lastWindow%
}
#Down::ToScratchpad()
#+Up::FromScratchpad()

Now let's go even further and use a stack of windows for that purpose! The next snippet saves the list of windows you minimized that way in a stack, and restores them in order:

global lastWindows := Array() ; this line needs to be at the top of the file
ToScratchpad(windows)
{
    WinGetTitle, lastWindow, A
    WinMinimize, %lastWindow%
    windows.Push(lastWindow)
}
FromScratchpad(windows)
{
    lastWindow := windows.Pop()
    WinActivate, %lastWindow%
}
#Down::ToScratchpad(lastWindows)
#+Up::FromScratchpad(lastWindows)

The first line has to be placed before the first return/hotkey, or it won't be executed (and the script will not work).

has to be placed before the first return/hotkey