Minimizing and maximizing all windows with a single hotkey

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
nelvin08
Posts: 97
Joined: 27 Mar 2022, 23:13

Minimizing and maximizing all windows with a single hotkey

Post by nelvin08 » 07 Feb 2023, 10:05

Hi,

So below is my code and it works. But sometimes when I have too many apps, the screen burns a trail of the app in the monitor when minimizing.

While when maximizing, it full screens / maximizes my task bar.

I am using 3 monitors by the way. Do I need to incorporate winwait somewhere?

Code: Select all

#MaxThreadsperHotkey 2
#D::

Previouskey:= !PreviousKey

if PreviousKey
{
GroupAdd, AllWindows
WinMaximize, ahk_group AllWindows
}
else
{
GroupAdd, AllWindows
WinMinimize, ahk_group AllWindows
}
return

User avatar
mikeyww
Posts: 26891
Joined: 09 Sep 2014, 18:38

Re: Minimizing and maximizing all windows with a single hotkey

Post by mikeyww » 07 Feb 2023, 13:24

To maximize only certain windows, you can specify them. WinGet can also be used to get a list. You can then exclude some windows.

For minimizing: https://www.autohotkey.com/docs/v1/lib/WinMinimizeAll.htm

nelvin08
Posts: 97
Joined: 27 Mar 2022, 23:13

Re: Minimizing and maximizing all windows with a single hotkey

Post by nelvin08 » 07 Feb 2023, 19:01

Thanks. I decided to retain the #D in-built function of Windows to show desktop and just put my code in #F

This somehow works but maybe you have something in mind to simplify this? or if you have a different approach?

Code: Select all

#F::
active_ID := WinActive("A")
WinGet, WindowList, List,,, Program Manager
Loop, %WindowList%
{
	WinGetClass, Class, % "ahk_id " . WindowList%A_Index%
	IF Class not contains Shell_TrayWnd,Shell_SecondaryTrayWnd
	WinRestore, % "ahk_id " . WindowList%A_Index%
}
WinActivate, % "ahk_id " active_ID
return

Post Reply

Return to “Ask for Help (v1)”