Page 1 of 1

Remember windows' position and size

Posted: 17 Nov 2014, 17:59
by zotune
Settings: Saved to WindowList.txt

https://bpaste.net/show/3c1fd705e5d8

Update 1: now requires TF library to sort windows - https://github.com/hi5/TF
Update 2: fixes
Update 3: more fixes, shows saved windows, requiring Notify - http://www.autohotkey.com/board/topic/4 ... ns-v04991/

Re: Remember windows' position and size

Posted: 21 Nov 2014, 09:31
by Skrell
?? What does this do? How does it work? etc...

Re: Remember windows' position and size

Posted: 21 Nov 2014, 10:05
by vasili111
Some more explanations and examples would be nice.

Re: Remember windows' position and size

Posted: 21 Nov 2014, 15:08
by zotune
[WIN] + [SHIFT] + [TAB]: Saves everything but your minimized windows position into WindowList.txt, even works if they're maximized or not.
[WIN] + [TAB]: Restores your saved windows positions, also maximizes them if they were saved like that.

Note: Uses process detection, will not work on multiple windows from the same process.

Re: Remember windows' position and size

Posted: 21 Nov 2014, 15:30
by kon
Good job. It's interesting to see your script.

In case you're interested, I wrote something similar for an "Ask for Help" topic. Link.
I don't plan on developing or maintaining it. Just thought it was worth mentioning, since the scripts are related. :)

Re: Remember windows' position and size

Posted: 30 Jan 2015, 07:42
by zotune
Thanks, I'll have a look :) Mine seems to work better now. I can use it to run processes with the same name, that way I can position duplicate simulators with different ports. I'll post the new script if anyone is interested (I'll have to extract it from my code)

Re: Remember windows' position and size

Posted: 16 Jun 2015, 12:53
by Mrshortcut
Any chance this code is still available?

Re: Remember windows' position and size

Posted: 17 Jun 2015, 06:50
by Guest10

Code: Select all

; http://ahkscript.org/boards/viewtopic.php?f=6&t=5166

#Include TF.ahk

; Settings: Saved to WindowList.txt
; Requires TF library to sort windows
; Save window profile (does not remember minimized windows):

!r::
DetectHiddenWindows Off

FileDelete, WindowList.txt
Remember=
WindowList=

WinGet, Window, List
Loop, %Window%
{
WinGet, Process, ProcessName, % "ahk_id " Window%A_Index%
        if (Process != "explorer.exe")
        {
        Remember=%Remember%%Process%`n
        }
}
 
StringSplit,Remember,Remember,"`n"
 
Loop, %Remember0%
{
Process:=Remember%A_Index%

		WinGetPos, X, Y, Width, Height, ahk_exe %Process%
		WinGet, MinMax, MinMax, ahk_exe %Process%

        if !InStr(WindowList,Process) and (Process != "") and (X != "") and (Y != "") and (Width != "") and (Height != "") and (Width != "0") and (Height != "0") and (MinMax != "") and (MinMax != "-1")
        {
			WindowList=%WindowList%%Process%|%X%|%Y%|%Width%|%Height%|%MinMax%`n
        }
}

WindowList:=TF_RemoveBlankLines(WindowList)
WindowList:=TF_ReverseLines(WindowList)

FileAppend, %WindowList%, WindowList.txt

Notify("Saved layout",,5)

DetectHiddenWindows On
 
Return
 
;Load window profile
#TAB::
DetectHiddenWindows Off

FileRead, WindowList, WindowList.txt
 
StringSplit,Rows,WindowList,"`n`r"
 
Loop, %Rows0%
{
        Win:=Rows%A_Index%
        StringSplit,Columns,Win,"|"
       
                        ;Restore if minimized
                       
                        Process, Exist, %Columns1%
                        IF errorlevel!=0
                        {
                                Minmax=
                                While (Minmax = "")
                                {
                                WinGet, MinMax, MinMax, ahk_exe %Columns1%
                                }
                               
                                If (MinMax = "-1")
                                {                      
                                        ;WinActivate, ahk_exe %Columns1%
                                        PostMessage, 0x112, 0xF120,,, ahk_exe %Columns1%
                                }
                        }
                       
                        ;Move to saved position
                        WinMove, ahk_exe %Columns1%,, %Columns2%, %Columns3%, %Columns4%, %Columns5%
                       
                        ;Maximize if saved as such
                        If (Columns6 = "1")
                        {
                                WinMaximize, ahk_exe %Columns1%
                        }
                       
                        ;Put the window at the top of other windows
                        WinSet, Top,, ahk_exe %Columns1%
}
 
DetectHiddenWindows On
Return

Re: Remember windows' position and size

Posted: 18 Jun 2015, 12:49
by Mrshortcut
Thanks!

Re: Remember windows' position and size

Posted: 12 Jul 2016, 02:44
by canisdibellum
kon wrote:Good job. It's interesting to see your script.

In case you're interested, I wrote something similar for an "Ask for Help" topic. Link.
I don't plan on developing or maintaining it. Just thought it was worth mentioning, since the scripts are related. :)
Kon....that was me you wrote that for andI have to tell you Ive gotten very much use out of it....very happy with it!