Opposite of WinMinimizeAll Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Opposite of WinMinimizeAll

09 May 2020, 14:15

Let's say I have 10 windows open. 5 are visible on the desktop, and the other 5 are minimized.

Now, I use the WinMinimizeAll command.

This minimizes the 5 windows which are currently visible.

Now to restore all the minimized windows (now a total of 10), how do I do that?

Pressing #d will restore only those 5 that were minimized when running the WinMinimizeAll command in the first place. The other 5 which were always in minimized state remain as so.

I thought that maybe there was a WinRestoreAll command (in opposition to WinMinimizeAll), but it doesn't look like that exists.

Anyone know of a way to get all those minimzed windows back to their restored state? Thanks...
Last edited by scriptor2016 on 09 May 2020, 14:22, edited 1 time in total.
User avatar
Smile_
Posts: 858
Joined: 03 May 2020, 00:51

Re: Opposite of WinMinimizeAll

09 May 2020, 14:19

WinMaximizeAll ?
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Re: Opposite of WinMinimizeAll

09 May 2020, 14:23

Hi thanks, but wouldn't that just maximize all those minimzed windows I was hoping to just restore those windows back to their original states, sizes and positions on the desktop.. not sure if this is possible tho...
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Re: Opposite of WinMinimizeAll

09 May 2020, 14:47

I tried this simple code. Pressing SHIFT+Z will minimize all windows on the desktop.

Problem is, pressing SHIFT+X (or WIN+D for that matter) doesn't restore them.

Code: Select all

+z::
winminimizeall
return

+x::
sendinput #d
return
I'm thinking that pressing WIN+D to restore windows will work, but only if WIN+D was used to minimize them in the first place. If they were minimzed using some other method (WinMinimizeAll for example), then WIN+D to restore them doesn't seem to work.

Basically how do we get all minimized windows (regardless of how they were minimized) back into their restored states

Maybe we have to loop through all windows, get their states, and if they are minimized, then restore them? I'm wondering if the restored state of these windows is saved somewhere in memory... otherwise it may not be able to access what its original state(size of window, position on desktop, etc) was before being minimized. I'm going to keep playing here :)
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Re: Opposite of WinMinimizeAll

09 May 2020, 15:10

Ok, maybe this is working now. Hoping this code will being all minimized windows back into their restored states:

Code: Select all

+z::
   
SetTitleMatchMode, 2
WinGet, id, list ,,,
Loop, %id%
{
    this_id := id%A_Index%
    WinGet, window_state, MinMax, ahk_id %this_id%,,,
 
    if (window_state = -1) ;this means the window is currently minimized
    WinRestore, ahk_id %this_id% ;restores the minimized window  
} 
takes a little bit of time though, it doesn't just do it all in one shot. You kind of see each window pop back into its restored state, one-by-one.
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: Opposite of WinMinimizeAll

09 May 2020, 16:05

This is simpler and a bit faster on my system:

Code: Select all

GroupAdd, AllWindows
return

$F1:: WinRestore ahk_group AllWindows
User avatar
Smile_
Posts: 858
Joined: 03 May 2020, 00:51

Re: Opposite of WinMinimizeAll

09 May 2020, 16:20

@scriptor2016
Like you got every opened window id and minimized it, you can't use that id again to restore them? (not all only minimized ones)
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Re: Opposite of WinMinimizeAll

09 May 2020, 17:02

thanks a lot guys!!! I'm still playing with this. I promise to report back here once I get this going (or more likely don't get this going lol).


What I'm finding is that when a window (or all windows at once?) are minimized, then it is somehow altering/resetting the "z-order" of all windows or something along those lines, which is affecting the order in which way some/all windows are restored.

Sorry I'm probably making no sense, but I'll keep trying to figure it out..
poetbox
Posts: 112
Joined: 18 Apr 2018, 20:47

Re: Opposite of WinMinimizeAll  Topic is solved

09 May 2020, 17:04

not tested.

Code: Select all

+z::
SetTitleMatchMode, 2
WinGet, id, list ,,,
Loop, %id%
{
    this_id := id%A_Index%
    WinGet, window_state, MinMax, ahk_id %this_id%,,,
 
    if (window_state != -1) ;this means the window is currently minimized
    GroupAdd, winminimizeall,ahk_id %this_id% ;restores the minimized window  
} 

winminimizeall
return

+x::
WinRestore ahk_group winminimizeall
return
poetbox
Posts: 112
Joined: 18 Apr 2018, 20:47

Re: Opposite of WinMinimizeAll

11 May 2020, 02:57

scriptor2016 wrote:
09 May 2020, 14:15
Let's say I have 10 windows open. 5 are visible on the desktop, and the other 5 are minimized.

Now, I use the WinMinimizeAll command.

This minimizes the 5 windows which are currently visible.

Now to restore all the minimized windows (now a total of 10), how do I do that?
If my answer is useful, please select it and mark this topic as "Solved". :superhappy: :mrgreen:
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Re: Opposite of WinMinimizeAll

12 May 2020, 23:33

Hi, yes, this one works! Thanks poetbox.. I hadn't looked closely enough at this topic to see your post (sorry!!!!)

It's perfect :)

On a side note I was having problems integrating "winminimizeall" into my code because it seems that every time that command happens, it shuffles the Z-order of the taskbar items, which was throwing off my scripting.

Basically, I was trying to do a number of things:

-Cycle and then Winactivate each instance of a YouTube window in Google Chrome
-Once the window has become active, then minimize all other windows on the taskbar. This would make it very easy to isolate the YouTube window, especially when we might have 15 or 20 other windows visible on the desktop at any given time

So the problem was Winminimizeall was shuffling the z-order of all YouTube windows on the taskbar. For example if there are 5 YouTube windows open (I don't use tabs, I open a new chrome.exe instance each time), then a hotkey would cycle (and activate through all of them) and then continue to loop round and round after it hits the last one. I couldn't figure this out because of the altering of the z-order upon winminimizeall, so it wouldn't successfully loop through each window (1,2,3,4,5...then 1,2,3,4,5... then 1,2,3,4,5 and so on).. instead it would do something like (3,5,2,4,1...and then when looping back round to the beginning again it would do something totally different like 5,1,4,2,3... and so on).. too much of a headache

To top it off, I decided that winminimize wasn't the right way to go anyways, seeing as that maybe I would like 2 or 3 YouTube windows visible at the same time and going this route wouldn't make that possible
poetbox
Posts: 112
Joined: 18 Apr 2018, 20:47

Re: Opposite of WinMinimizeAll

15 May 2020, 00:00

Code: Select all

+z::
SetTitleMatchMode, 2
WinGet, id, list ,,,
new_id:={}
Loop, %id%
{
    this_id := id%A_Index%
    WinGet, window_state, MinMax, ahk_id %this_id%,,,
    ;MsgBox %this_id%
    if (window_state != -1) ;this means the window is currently minimized
    ;GroupAdd, winminimizeall,ahk_id %this_id% ;restores the minimized window  ;don't winminimizeall
	{
	new_id.push(this_id)  ;record the order
	;MsgBox % new_id.MaxIndex()
	WinMinimize ahk_id %this_id%
    }


} 

;winminimizeall   ;delete to deal with them one by one
return

+x::
;======old code.the order is out of control=========
;WinRestore ahk_group winminimizeall
;======the order maybe right,but it reversed indeed============
;for each, id in new_id
;WinRestore ahk_id %id%
;======the order maybe right,just have a try===============
num:=new_id.MaxIndex()
loop, % num
   { order:=num - A_Index +1
	WinRestore % "ahk_id " new_id[order]
}
return


What you said is very complicated, and I can't reproduce these problems on my computer too.My only advice is to deal with them one by one and restore them one by one.I think Push and pop will keep the order.But I'm not sure.After all,my programming skill is not so good either.
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Re: Opposite of WinMinimizeAll

16 May 2020, 13:09

Hi poetbox, I spent days on it - and the z-order keeps shuffling no matter what. I'm sure there's a math to it and its not just random in the way it shuffles the order, but it's not worth the headache - I decided to not minimize anything and instead paint a colored border around the active YouTube window each time the next one is activated. Seems to work so far. I could always post the code if you were interested in trying it out.
poetbox
Posts: 112
Joined: 18 Apr 2018, 20:47

Re: Opposite of WinMinimizeAll

24 May 2020, 07:16

scriptor2016 wrote:
16 May 2020, 13:09
Hi poetbox, I spent days on it - and the z-order keeps shuffling no matter what. I'm sure there's a math to it and its not just random in the way it shuffles the order, but it's not worth the headache - I decided to not minimize anything and instead paint a colored border around the active YouTube window each time the next one is activated. Seems to work so far. I could always post the code if you were interested in trying it out.
What about my new code above?It maybe useful.
Thank you very much for your kindness.Since I haven't the problem, I needn't the code to solve it.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 144 guests