Remember windows' position and size

Post your working scripts, libraries and tools for AHK v1.1 and older
zotune
Posts: 85
Joined: 17 Nov 2014, 17:57

Remember windows' position and size

17 Nov 2014, 17:59

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/
Last edited by zotune on 21 Nov 2014, 15:12, edited 1 time in total.
Skrell
Posts: 302
Joined: 23 Jan 2014, 12:05

Re: Remember windows' position and size

21 Nov 2014, 09:31

?? What does this do? How does it work? etc...
vasili111
Posts: 747
Joined: 21 Jan 2014, 02:04
Location: Georgia

Re: Remember windows' position and size

21 Nov 2014, 10:05

Some more explanations and examples would be nice.
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
zotune
Posts: 85
Joined: 17 Nov 2014, 17:57

Re: Remember windows' position and size

21 Nov 2014, 15:08

[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.
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Remember windows' position and size

21 Nov 2014, 15:30

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. :)
zotune
Posts: 85
Joined: 17 Nov 2014, 17:57

Re: Remember windows' position and size

30 Jan 2015, 07:42

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)
Mrshortcut
Posts: 21
Joined: 19 Feb 2015, 20:15

Re: Remember windows' position and size

16 Jun 2015, 12:53

Any chance this code is still available?
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: Remember windows' position and size

17 Jun 2015, 06:50

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
canisdibellum
Posts: 47
Joined: 09 Oct 2014, 11:44

Re: Remember windows' position and size

12 Jul 2016, 02:44

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!

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: KruschenZ, william_ahk and 130 guests