Page 1 of 1

Minimize and again Maximize the same window

Posted: Jul 27th, ’25, 06:17
by Admirer
I use this script to minimize the topmost open window with the shortcut ctrl+space: WinMinimize, A
Is it possible to maximize it again using the same command?
I mean : ctrl+space - 1st instance - minimize the topmost open window and
ctrl+space - 2nd instance - maximize the same window

Re: Minimize and again Maximize the same window

Posted: Aug 3rd, ’25, 08:56
by Tom
Something like this?

Code: Select all

If not WinTitle
{
	WinGetActiveTitle, WinTitle
	WinMinimize, A
}
else
{
	WinRestore, % WinTitle
	WinActivate, % WinTitle
	WinTitle:=""
}
return

Re: Minimize and again Maximize the same window

Posted: Aug 13th, ’25, 11:43
by Admirer
I pasted the above code in Fastkeys short cut Ctrl+space.

I opened the browser and then I opened the notepad. I pressed the above short cut (Ctrl+space) and the notepad window got minimized. I again pressed the same short cut, but this time the notepad didn't return to its original position.

Re: Minimize and again Maximize the same window

Posted: Sep 2nd, ’25, 18:44
by Marko
You need to make sure the window is actually active, click on the header to be sure. Also try this:

Code: Select all

If not WindowID
{
	WinGet WindowID, ID, A
	WinMinimize, ahk_id %WindowID%
}
else
{
	WinActivate, ahk_id %WindowID%
	WinRestore, ahk_id %WindowID%
	WindowID:=""
}
return

Re: Minimize and again Maximize the same window

Posted: Sep 8th, ’25, 13:06
by Admirer
Wow! That hits the bull's eye!
Needless to say this is going to be one of the most frequently used shortcuts during my PC work. So often do we require to alternate between a browser and a word doc or a browser and a spreadsheet.
Thank you.