Minimize and again Maximize the same window

Share your favorite FastKeys commands
Post Reply
Admirer
Posts: 26
Joined: Aug 19th, ’19, 05:19

Post by Admirer » Jul 27th, ’25, 06:17

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
User avatar
Tom
Posts: 917
Joined: Nov 24th, ’15, 23:39

Post by Tom » Aug 3rd, ’25, 08:56

Something like this?

Code: Select all

If not WinTitle
{
	WinGetActiveTitle, WinTitle
	WinMinimize, A
}
else
{
	WinRestore, % WinTitle
	WinActivate, % WinTitle
	WinTitle:=""
}
return
Admirer
Posts: 26
Joined: Aug 19th, ’19, 05:19

Post by Admirer » Aug 13th, ’25, 11:43

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.
User avatar
Marko
Posts: 1924
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Sep 2nd, ’25, 18:44

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
Admirer
Posts: 26
Joined: Aug 19th, ’19, 05:19

Post by Admirer » Sep 8th, ’25, 13:06

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.
Post Reply