1

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.

Stevoisiak
  • 23,794
  • 27
  • 122
  • 225
Deqing
  • 14,098
  • 15
  • 84
  • 131
  • Those are standard methods and should work if you correctly specify window title and /or class. – wOxxOm Jul 04 '17 at 09:44
  • @StevenVascellaro thanks for your answer, it solved my question. Btw I'm using `ahk_group` now, meaning a hotkey can swap through same class of windows, e.g. all browser windows. – Deqing Oct 13 '17 at 04:03

1 Answers1

2

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

Stevoisiak
  • 23,794
  • 27
  • 122
  • 225