I'm looking for a way to show/hide a window with a specific title. One example is when you press win+1
, the first window at task bar will show, when you press again, it will be minimized.
I checked this page, but the methods they suggested are not working at my end.
You check whether a specific window has been minimized with WinGet. (Credit to Laszlo)
WinGet WinState, MinMax, %WinTitle% ; Retrieve minimized/maximized state
You can then show or hide said window with WinMinimize and WinRestore.
#m::WinMinimize, Untitled - Notepad ; Minimize window to taskbar
#r::WinRestore, Untitled - Notepad ; Unminimize or unmaximize window
The hotkey below checks a window's state, then minimizes or unminimizes the window.
#1::
WinTitle := "Untitled - Notepad"
WinGet WinState, MinMax, %WinTitle% ; retrieve minimized/maximized state
if (WinState = -1) ; minimized
WinRestore, %WinTitle%
else ; not minimized
WinMinimize, %WinTitle%
Return
See Also