Stilez

Accurate code to restore minimized windows state

4 posts in this topic

#1 ·  Posted (edited)

I was playing round with WinMinimizeAll() and WinMinimizeAllUndo(). If you have popup dialogs etc in between, sometimes the WinMinimizeAllUndo() "forgets" which windows were minimized by WinMinimizeAll() so it doesn't do the restore function as you'd expect.

For anyone who hits this, the following code will handle it - and allow arbitrary window manipulation in between. It logs all non-minimized window handles, and when you're done, it checks for any windows that are displayed now, were displayed before (according to its handle) and whose state has changed from non-minimized to minimized, and restores it.

Things it doesn't do - it doesn't handle clashes of window handles, and it doesn't remember the active window (their Z-order). If anyone wants to fix for those, please do!

#Include <Array.au3>


dim $OriginalNonMinimizedWindows[1]
$OriginalNonMinimizedWindows[0]=""

$winlist  = WinList()
If $winlist[0][0] > 0 Then
    for $i = 1 to $winlist[0][0]
        $winhdl = $winlist[$i][1]
        $state = WinGetState($winhdl)
        If BitAND($state,16) <> 16 Then _ArrayAdd($OriginalNonMinimizedWindows, $winhdl)
    Next
EndIf
_ArraySort($OriginalNonMinimizedWindows)

WinMinimizeAll()
sleep (1500)

$winlist = Winlist()
If $winlist[0][0] > 0 Then
    For $i = 1 to $winlist[0][0]
        $winhdl = $winlist[$i][1]
        $state = WinGetState($winhdl)
        If BitAND($state, 16) == 16 Then
            If _ArrayBinarySearch($OriginalNonMinimizedWindows, $winhdl) >= 0 Then 
                WinSetState($winhdl, "", @SW_RESTORE)
                msgbox(1,"","Restored window for: " & $winlist[$i][0] & " (handle "& $winlist[$i][1] & ").", 1)
            EndIf
        EndIf
    Next
EndIf
Edited by Stilez

Share this post


Link to post
Share on other sites



Hi, 
I know this is an old post.. 6 years ago.
Your code worked well for me, except I stopped Explorer process.
All the windows restored, except an open Folder.  Its not really a problem,
I'm just curious as to how to save info for an open folder to be restored.

Share this post


Link to post
Share on other sites

Not sure you are in a hurry for an answer from @Stilez, but he's not been visiting the forum since august 2011.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

oh I see.
Well, I may try to find out, or remain curious.
I suppose I would have to detect if a window is a folder.
Then save the information and then figure out code to open a folder.
Probably with a lot of google searching.
Hey, opening a folder isn't so difficult.  Now to find out how to save the info.

 

Edited by JoeP8
more related info

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now