Automatically Restore Last Window Position For Each Process

Post your working scripts, libraries and tools for AHK v1.1 and older
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: Automatically Restore Last Window Position For Each Process

26 Mar 2018, 06:27

ovnis wrote:Hello Brutus,

Thx for your script, but there are problems.

There are issues with Taskmgr.exe and explorer.exe. Windows don't appear at the right place.
Edit: Fixed version on next post.
Last edited by brutus_skywalker on 27 Mar 2018, 02:40, edited 1 time in total.
Outsourcing Clicks & Presses Since 2004.
ovnis
Posts: 12
Joined: 25 Mar 2018, 13:40

Re: Automatically Restore Last Window Position For Each Process

26 Mar 2018, 12:55

Edit: you might alternatively try 'Title' based repositioning i added in my last edit to my version of the script,it might be more precise,at least for task manager.
But "Title_Filter" adds windows to the automatic window manager or the opposite ?

I use your last script. But with title filter, i don't figure out how to manage better explorer folder or the taskmanager.

Otherwise, is not possible to add a filter with whom "ahk_class #32770" or "ahk_class CabinetWClass" are automatically saved ?

One note, Firefox, Windows 10 mail haven't box. :)
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: Automatically Restore Last Window Position For Each Process

27 Mar 2018, 02:39

Edit: removed a bad post.
Last edited by brutus_skywalker on 27 Mar 2018, 07:35, edited 1 time in total.
Outsourcing Clicks & Presses Since 2004.
ovnis
Posts: 12
Joined: 25 Mar 2018, 13:40

Re: Automatically Restore Last Window Position For Each Process

27 Mar 2018, 05:38

Hi,

Same issue with taskmgr.exe et explorer.exe. OneNote, Windows mail doesn't work anymore.
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: Automatically Restore Last Window Position For Each Process

27 Mar 2018, 07:40

ovnis wrote:Hi,

Same issue with taskmgr.exe et explorer.exe. OneNote, Windows mail doesn't work anymore.

Yeah, my code got really tangled, with the original authors code,so i've decided to rewrite the concept with the simplicity that it implicitly should have,so i'll post it here when i have time, i reckon i can shrink it down to <50lines and actually make it readable. Cheers & sorry for my previous bad post. But if in the mean time my last code post should be more functional with just the taskmgr & explorer kinks...
Outsourcing Clicks & Presses Since 2004.
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: Automatically Restore Last Window Position For Each Process

29 Mar 2018, 12:31

Rewrote my version of the OP, it took more code than the 50 lines i was hoping for the rewrite, and even ended up being more than the original code, to make it easier to maintain, more efficient & easier to modify for anyone who wants to modify to their whims. It now uses ProcessName,ClassName,WindowStyle to uniquely identify windows, uses PID for window management sessions(move window on first run only), only saves position data from windows that are niether maximised nor minimised and idles until active window belongs to a managed process.

Recommend adding and removing managed processes using the default hotkey, Ctrl+Shift+Ins.

Known Issues:
  • If explorer.exe is added as a managed process, ensure the class names saved to INI are of the actual explorer window, and not the start menu or such,which are also windows under explorer.exe...

    It uses first encounter window attributes to pair a window's attributes with a designated ManagedProcess,i.e if a process has a dialog box open when it's first encountered then that dialog box will be identified as the processes main window, so if that is the case, simply remove the INI entry and have it detect the window again or modify INI entry manually using the script provided below.

    NOT COMPATIBLE WITH Windows 10 Universal Windows Platform apps(ApplicationFrameHost.exe apps), TESTED ON WinXP/7/8/10.
Script to gather info about active window,to verfiy window identifiers in INI are the correct ones.

Code: Select all

;Display in real time the active window's style,class & exe+PID  -- use snippet to manually modify attributes in INI,using information collected here.
#Persistent
SetTimer, WatchActiveWindow, 200
Esc::ExitApp
WatchActiveWindow:
WinGet, this_exe, ProcessName, A
WinGet, this_pid, PID, A
WinGetClass, this_class, A
WinGet, this_style, style, A
ToolTip, style: %this_style% class: %this_class% exe: %this_exe% pid: %this_pid%
Clipboard = style: %this_style% class: %this_class% exe: %this_exe% pid: %this_pid%
return
EDIT(FIXES):
  • Now properly handles snapped windows,it didn't before.My Bad...

    Multimonitor compatible,at least it should be, i can't test it(single monitor setup) but logically code no longer has hardcoded boundries like it did before.
EDIT(FIXES):
  • Added Hotkey 'Ctrl+Shift+Ins' to add or remove windows to managedProcesses list, easier and more precise addition of windows.
    >If window is already managed user will be prompted to remove managed processes, else user will be prompted to add active window to managed processes list.

    NOTE ON HOTKEY: hotkey neither adds nor removes to managedProcesses added manually to script, instead it only manages managedProcesses added by Hotkey,reasoning for this is simply a matter of personal preference, nothing more.

    Optimised core logic to make it more reliable and less likely to trigger unexpected outcomes.
FINAL EDIT:
  • Now uses unique window ID's instead of PID to manage window management sessions, such that a process with multiple managed windows will have them all managed instead of only the very first one as was the case before. i.e new explorer windows for example under a single process(identical PID's) will now all be managed instead of only the very first explorer window,a very silly bug that's now squashed.

AutomaticWindowManager-v2-

Code: Select all

; Automatically Restore Previous Window Size/Pos
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#Persistent
#SingleInstance, Force
#NoTrayIcon
Process, Priority, , Normal
;get monitor count
SysGet, numberOfMonitors, MonitorCount


;==================================================== CONFIGURATION SECTION =====================================================================================================
;list of processes to resize & reposition automatically - note the main class of a process listed here will be the class name registered when a listed process window is first encountered.
managedProcesses = xulrunner.exe,firefox.exe,notepad.exe,chrome.exe,notepad++.exe,ProcessHacker.exe,Cmd.exe,mintty.exe,FoxitReader.exe,taskmgr.exe
;class names that prevent an active window with a listed class from being managed, seprate with commas.
excludedClassList = 
;titles that prevent an active window with a listed title & belonging to a managed processes from being managed, add titles on newlines.
excludedTitlesList =
(
any window title delimited by lines will exclude that window from being managed - every title should be on a new line
)
;==================================================== END OF CONFIGURATION SECTION ==============================================================================================


;append dynamicallyManagedProcesses to managedProcesses list
dynamicallyManagedProcesses := INI("r", "dynamically managed processes", "dynamicallyManagedProcessesList")
managedProcesses .= "," dynamicallyManagedProcesses	;update managedProcesses with dynamicallyManagedProcesses on init.


	

	
Loop						;main execution loop
	Main()

	
	
	

;to add or remove additional windows as managed processes with a single hotkey,NOTE:this hotkey CAN NOT remove managed processes defined above,only those added by hotkey
^+Ins::Add_RemoveDynamicallyManagedProcess()




Main(){
Global
ActiveWinStats()

;sessionIDlist references PID of windows that have already been restored using data from previous process sessions,it ensures a window with it's pid in the list isn't moved again until new process.
If (activeWinIsManaged AND !InStr(sessionIDlist, activeWindowID)){
	SetWinPos()
	}
Else If(activeWinIsManaged AND InStr(sessionIDlist, activeWindowID)){
	SaveWinPos()
	}

;wait until active window is a managed process
While !IsContainedIn(managedProcesses, activeProcessName){
	WinGet, activeProcessName, ProcessName, A
	Sleep, 100
	}
}

;=================================================================================================================================================

ActiveWinStats(){	;returns active window title, position, class, style, PID & parent exe, by populating global variables
Global
WinGetActiveStats, activeTitle, activeWidth, activeHeight, active_X, active_Y
WinGetClass, activeClass, A
WinGet, activeProcessName, ProcessName, A
WinGet, activeStyle, Style, A
WinGet, activeProcessPID, PID, A	;to track active process session,so that this process is only acted upon if it's PID isn't listed as being processed,it's reset when process dies.
WinGet, activeWindowID, ID, A	;to track active process session,so that this process is only acted upon if it's PID isn't listed as being processed,it's reset when process dies.
WinGet, activeWinIsMaxOrMin, MinMax, A		;returns false/0 if active win is niether maximised nor minimised,i.e 'candidate be repositioned & resized'

statsDebug:= activeTitle "`n" activeWidth "`n" activeHeight "`n" active_X "`n" active_Y "`n" activeClass "`n" activeProcessName "`n" activeWindowID "`n" activeStyle "`n" activeWinIsMaxOrMin
; ToolTip, %statsDebug%

If ( IsContainedIn(managedProcesses, activeProcessName) AND !IsContainedIn(excludedClassList, activeClass) AND !IsContainedIn(excludedTitlesList, activeTitle) AND !activeWinIsMaxOrMin){
	activeWinIsManaged := true
	}
Else activeWinIsManaged := false
}

;==========================================================================================================================================================================
;=====================================  Functions to resize & reposition managed windows according to exclusion rules  ====================================================
;==========================================================================================================================================================================

SetWinPos(){		;saves position of window after moving it to previous session size and position
Global
GetWinStats()
;verify window is valid window and not a child window of a mananged processes
If  AllPairsMatch(activeProcessName "|" thisProcessName, activeClass "|" thisProcClass, activeStyle "|" thisProcStyle){
	;if activee window's position data doesn't match stored position data move it
	If !AllPairsMatch(activeHeight "|" thisProcHeight, activeWidth "|" thisProcWidth, active_X "|" thisProcX, active_Y "|" thisProcY){
		sessionIDlist .= activeWindowID	"`, " 	;register active window ID so that it's no longer moved again,but it's position is updated for future sessions
		;if active window attributes are not out of bounds proceed
		If(active_X > -1 AND active_Y > -1 AND activeWidth < A_ScreenWidth AND activeHeight < A_ScreenHeight AND activeWidth > 0 AND activeHeight > 0 AND numberOfMonitors = 1){
			MoveWin()
			}
		Else If(active_X AND active_Y AND activeWidth AND activeHeight AND numberOfMonitors > 1){	;If morethan one monitor !unable to test reliability due to single monitor setup.
			MoveWin()
			}
		}
	Else	;if AllPairsMatch...
		sessionIDlist .= activeWindowID	"`, " 	;register active window ID so that it's no longer moved again,if it was repositioned to previous position by itself or other means.
	}
}

;=================================================================================================================================================

SaveWinPos(){		;saves position of a window that has already been moved to position & size of previous session for future sessions
Global
GetWinStats()
;verify window is valid window and not a child window of a mananged processes
If  AllPairsMatch(activeProcessName "|" thisProcessName, activeClass "|" thisProcClass, activeStyle "|" thisProcStyle){
	;if activee window's position data changes from stored data, save it to update saved data
	If !AllPairsMatch(activeHeight "|" thisProcHeight, activeWidth "|" thisProcWidth, active_X "|" thisProcX, active_Y "|" thisProcY){
		;if active window attributes are not out of bounds, proceed with saving data
		If(active_X > -1 AND active_Y > -1 AND activeWidth < A_ScreenWidth AND activeHeight < A_ScreenHeight AND activeWidth > 0 AND activeHeight > 0 AND numberOfMonitors = 1){
			SaveWinStats()
			}
		Else If(active_X AND active_Y AND activeWidth AND activeHeight AND numberOfMonitors > 1){	;If morethan one monitor !unable to test reliability due to single monitor setup.
			SaveWinStats()
			}
		}
	}
}

;==========================================================================================================================================================================
;==========================================================================================================================================================================
;==========================================================================================================================================================================

MoveWin(){
Global
WinActivate, ahk_pid %activeProcessPID%			;For those times windows fail to get resized because another window took focus. Yea even with PID based move, that is an issue!
WinMove, ahk_pid %activeProcessPID%,, %thisProcX%, %thisProcY%, %thisProcWidth%, %thisProcHeight%	;SetPos of identified managed window based on it's PID.
activeProcessStats := activeProcessName "`," thisProcWidth "`," thisProcHeight "`," thisProcX "`," thisProcY "`," activeClass "`," activeStyle
INI("w", "managed processes",activeProcessName, activeProcessStats)
Sleep, 1000	;safeguard against write & repositioning delay
}

;=================================================================================================================================================
 
SaveWinStats(){
Global
activeProcessStats := activeProcessName "`," activeWidth "`," activeHeight "`," active_X "`," active_Y "`," activeClass "`," activeStyle
INI("w", "managed processes",activeProcessName, activeProcessStats)
Sleep, 100	;safeguard against write delay
}

;=================================================================================================================================================

GetWinStats(){		;gets previously recorded stats for active process as well as refreshing active window stats
Global
ActiveWinStats()
thisProcessStats := INI("r", "managed processes", activeProcessName)
Sleep, 100	;safeguard against read delay
StringSplit, statArray, thisProcessStats, `,
thisProcessName:=statArray1, thisProcWidth:=statArray2, thisProcHeight:=statArray3, thisProcX:=statArray4, thisProcY:=statArray5, thisProcClass:=statArray6, thisProcStyle:=statArray7
;if managedProcesses is detected for first time, set thisProc* attribs to current to allow it to be saved to INI
If activeWinIsManaged	;safeguard against unmanaged windows being registered
	IfNotInString, thisINI, %activeProcessName%
		thisProcessName:=activeProcessName, thisProcClass:=activeClass, thisProcStyle:=activeStyle
}

;=================================================================================================================================================

IsContainedIn(haystack, needle){	;if Needle is contained in Haystack it returns true - Haystack must be comma delimited or line delimited
IfNotInString, haystack, `n	;if not line delimited
	{
	Loop, Parse, haystack, `,
		IfEqual, needle, %A_LoopField%
			Return True
	}
Else
	{
	Loop, Parse, haystack, `n
		IfEqual, needle, %A_LoopField%
			Return True
	}	
}

;=================================================================================================================================================

; MsgBox, % AllPairsMatch("do|doo", x "|" y)
AllPairsMatch(pairs*){	;each pair must be a single function parameter delimited by '|', ex. AllPairsMatch(varA "|" varB)
for index,pair in pairs
	{
	numberOfPairs++
	StringSplit, pairArray, pair, |
	IfEqual, pairArray1, %pairArray2%
		pairsMatched++		;increment for every pair matched
	}
IfEqual, pairsMatched, %numberOfPairs%	;all pairs match
	Return true
}

;=================================================================================================================================================

INI(rw, ini_section, ini_key, key_value:="", key_default_value:=" ", ini_file:="WindowSizePosLog.ini"){	;r/w - 'r' to read & 'w' to write to ini | 'd' delete INI key
Global thisINI
FileRead, thisINI, %ini_file%	;global var with INI file contents
If (rw = "r"){	;read from ini
	IniRead, thisKeyVal, %ini_file%, %ini_section%, %ini_key%, %key_default_value%
	; FileAppend, [%A_Now%] [READ] %ini_section% --> %ini_key% --> %key_value%`n, %ini_file%.LOG.log	;log INI reads
	Return, thisKeyVal
	}
Else If (rw = "w"){	;write to ini
	IniWrite, %key_value%, %ini_file%, %ini_section%, %ini_key%
	FileAppend, [%A_Now%] [WRITE] %ini_section% --> %ini_key% --> %key_value%`n, %ini_file%.LOG.log	;log INI writes
	}
Else If (rw = "d"){	;delete key from ini
	IniDelete, %ini_file%, %ini_section%, %ini_key%
	FileAppend, [%A_Now%] [DELETE] %ini_section% --> %ini_key% `n, %ini_file%.LOG.log	;log INI writes
	}
}

;=================================================================================================================================================

Add_RemoveDynamicallyManagedProcess(){	;if active process is managed process it prompts to remove it and if it's not it prompts to add it to managedProcesses list.
Global
ActiveWinStats()
dynamicallyManagedProcesses := INI("r", "dynamically managed processes", "dynamicallyManagedProcessesList")
this_dynamicallyManagedProcesses := ""
If !InStr(dynamicallyManagedProcesses , activeProcessName){		; if active window is not managed,add it.
	MsgBox, 0x40041, %A_ScriptName%, ADD Active Window as a Managed Process? `n`n %activeProcessName% `n %activeClass% `n %activeStyle%
	IfMsgBox, OK
		{
		INI("w", "dynamically managed processes","dynamicallyManagedProcessesList", dynamicallyManagedProcesses "`," activeProcessName)
		SaveWinStats()
		}
	}
Else If InStr(dynamicallyManagedProcesses , activeProcessName){	;if active window is already managed remove it as managedProcesses by rebuilding dynamicallyManagedProcessesList with out it.
	MsgBox, 0x40031, %A_ScriptName%, Remove Window as a Managed Process? `n`n %activeProcessName% `n %activeClass% `n %activeStyle%
	IfMsgBox, OK
		{
		Loop, Parse, dynamicallyManagedProcesses, `,	;rebuild list minus removed process
			IfNotInString, A_LoopField, %activeProcessName%
				If A_LoopField	;if loop field contains anything
					this_dynamicallyManagedProcesses .= A_LoopField ","
		dynamicallyManagedProcesses := this_dynamicallyManagedProcesses
		INI("w", "dynamically managed processes","dynamicallyManagedProcessesList", dynamicallyManagedProcesses)
		StringReplace, managedProcesses, managedProcesses, %activeProcessName%, , All	;remove process from primary managedProcesses list
		INI("d", "managed processes", activeProcessName)	;remove process pos data from INI
		}
	}	
	
;update managedProcesses with dynamicallyManagedProcesses
dynamicallyManagedProcesses := INI("r", "dynamically managed processes", "dynamicallyManagedProcessesList")
IfNotInString, managedProcesses, %dynamicallyManagedProcesses%
	managedProcesses .=  "," dynamicallyManagedProcesses
}
Last edited by brutus_skywalker on 12 Apr 2018, 04:20, edited 8 times in total.
Outsourcing Clicks & Presses Since 2004.
ovnis
Posts: 12
Joined: 25 Mar 2018, 13:40

Re: Automatically Restore Last Window Position For Each Process

29 Mar 2018, 17:17

Hello,

Thx for your code, but "AutomaticWindowManager-v2-" works not as good than previous scripts... Explorer.exe,taskmgr.exe,ApplicationFrameHost.exe (OneNote, Skype, Mail etc.) don't work.

notepad.exe behaviour is strange...

file.ahk doesen't work :error paramter #2 invalid
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: Automatically Restore Last Window Position For Each Process

29 Mar 2018, 23:59

ovnis wrote:Hello,

Thx for your code, but "AutomaticWindowManager-v2-" works not as good than previous scripts... Explorer.exe,taskmgr.exe,ApplicationFrameHost.exe (OneNote, Skype, Mail etc.) don't work.

notepad.exe behaviour is strange...

file.ahk doesen't work :error paramter #2 invalid
Fixed file.ahk, it was a typo from when i posted, as for explorer.exe & taskmgr.exe i tested them explicitly for about 2days, no issues on win7/8, and as for all applications that use ApplicationFrameHost.exe as parent exe, that is a given they won't work,there can only be one ini entry for a managed process(exe), and for those that don't such as notepad.exe i suggest you use the fixed 'file.ahk' to manually change classname & style in the .INI file,and check the log file next to the ini for more info on malfunctions.

Cheers.
Outsourcing Clicks & Presses Since 2004.
jeka
Posts: 8
Joined: 30 Mar 2018, 05:24

Re: Automatically Restore Last Window Position For Each Process

30 Mar 2018, 05:32

brutus_skywalker wrote:Rewrote my version of the OP, it took more code than the 50 lines i was hoping for the rewrite, and even ended up being more than the original code, to make it easier to maintain, more efficient & easier to modify for anyone who wants to modify to their whims. It now uses ProcessName,ClassName,WindowStyle to uniquely identify windows, uses PID for window management sessions(move window on first run only), only saves position data from windows that are niether maximised nor minimised and idles until active window belongs to a managed process.
I wonder why this script does not launch (I don't see AutoHotkey icon in the system tray). But file.ahk launches and works. Incidentally, the very first script from OP works, albeit with dialog boxes issue reported earlier.

I'm on Win7 64b Ultimate. Any ideas?
ovnis
Posts: 12
Joined: 25 Mar 2018, 13:40

Re: Automatically Restore Last Window Position For Each Process

30 Mar 2018, 06:33

for all applications that use ApplicationFrameHost.exe as parent exe, that is a given they won't work
I have some difficulty to understand you (the english is not my native language). Your last script will not work with Onenote, Mail and Skype ? If this is the case, your last script has strictly no interest for me. :(
as for explorer.exe & taskmgr.exe i tested them explicitly for about 2days, no issues on win7/8,
I only use Windows 10. And explorer.exe & taskmgr.exe don't work.
Last edited by ovnis on 30 Mar 2018, 07:42, edited 1 time in total.
ovnis
Posts: 12
Joined: 25 Mar 2018, 13:40

Re: Automatically Restore Last Window Position For Each Process

30 Mar 2018, 06:36

I wonder why this script does not launch (I don't see AutoHotkey icon in the system tray).
Because, I don't understand why but inside the script there is #NoTrayIcon. :)
jeka
Posts: 8
Joined: 30 Mar 2018, 05:24

Re: Automatically Restore Last Window Position For Each Process

30 Mar 2018, 07:48

ovnis wrote:
I wonder why this script does not launch (I don't see AutoHotkey icon in the system tray).
Because, I don't understand why but inside the script there is #NoTrayIcon. :)

I see. Thanks. Still, I don't see any effect of the script AutomaticWindowManager-v2, but the very AutomaticWindowManager script works.

Am I still missing something?
ovnis
Posts: 12
Joined: 25 Mar 2018, 13:40

Re: Automatically Restore Last Window Position For Each Process

30 Mar 2018, 09:54

Still, I don't see any effect of the script AutomaticWindowManager-v2,
Me too (and too much complicated for my use). For the moment I stay on the first script. His only issue is than I would prefer than the script manages only programs reported in an filter list. Actually it manages all programs, that can be an issue (box issue with programs which work without bug with the native Windows snaping/recall).
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: Automatically Restore Last Window Position For Each Process

30 Mar 2018, 10:58

So the -v2- rewrite does work, i disable tray icon as it's a preference of mine,given i run 50+ scripts on my system, i use https://autohotkey.com/board/topic/26153-ahkcontrol/ to manage my scripts,i've commented it out though,if it's important apparently.

Unlike the OP script, -v2- only manages processes added to 'managedProcesses' variable,hence you have to define the process that you want to add, i could add a hotkey but i think anyone who wants to can do that anyways, the point of the rewrite was to simply make this concept modular and easily modifiable without imposing my preference on others.

So in a nut shell if you want the -v2- version to manage any window, just add the exe of the process the window belongs to, to the managedProcesses variable which should be near the top of the script, it's this line:
managedProcesses = xulrunner.exe,firefox.exe,notepad.exe,chrome.exe,notepad++.exe,ProcessHacker.exe,Cmd.exe,mintty.exe,FoxitReader.exe,taskmgr.exe

As for windows 10, let me reiterate, anywindows that share the same executable as 'Universal Windows Apps' such as OneNote, Mail,... will not work in a desired manner, i.e It might save the position of a window in the 'OneNote' app but it'll use that position to resize & reposition the 'Mail' app as they share a class name, a parent exe & almost always window style. As such i don't recommend you use it in windows 10 with windows 10 exclusive apps, or any app from the windows store as it is a 'Universal Windows App', i simply don't know how to better clarify this matter.
Outsourcing Clicks & Presses Since 2004.
jeka
Posts: 8
Joined: 30 Mar 2018, 05:24

Re: Automatically Restore Last Window Position For Each Process

30 Mar 2018, 11:20

brutus_skywalker wrote:
So in a nut shell if you want the -v2- version to manage any window, just add the exe of the process the window belongs to, to the managedProcesses variable which should be near the top of the script, it's this line:
managedProcesses = xulrunner.exe,firefox.exe,notepad.exe,chrome.exe,notepad++.exe,ProcessHacker.exe,Cmd.exe,mintty.exe,FoxitReader.exe,taskmgr.exe
Ah, I see. Well, I see 'mintty.exe' in there already. However v2 script does not manage 'mintty.exe' for me. I also tried to add 'gvim.exe' to the var, which also does nothing. Any pointers? Btw, I used file.ahk to identify correctly process names.
jeka
Posts: 8
Joined: 30 Mar 2018, 05:24

Re: Automatically Restore Last Window Position For Each Process

30 Mar 2018, 11:28

Playing a bit more with v2, noticed that if I resize-reposition mintty.exe window in the main monitor, the position is remembered/restored. If I move mintty.exe to the secondary, then close and re-open, it opens up in the last position for the main monitor. Is this expected?
jeka
Posts: 8
Joined: 30 Mar 2018, 05:24

Re: Automatically Restore Last Window Position For Each Process

30 Mar 2018, 11:32

Update: the OP version works correctly across both displays.
jeka
Posts: 8
Joined: 30 Mar 2018, 05:24

Re: Automatically Restore Last Window Position For Each Process

30 Mar 2018, 11:35

Here's how WindowSizePosLog.ini looks after frist running v2 then OP, perhaps it will shed some light.

[managed processes]
mintty.exe=mintty.exe,451,1446,515,12,mintty,0x14EF0000
gvim.exe=gvim.exe,415,813,6,329,Vim,0x16CF0000
notepad.exe=notepad.exe,484,1099,21,73,Notepad,0x14CF0000
[Process Names]
Explorer.EXE=-2210,554,797,1099
gvim.exe=-2369,689,577,866
taskmgr.exe=-1146,856,710,498
chrome.exe=-2569,471,2578,1426
NOTEPAD.EXE=21,73,1083,1810
ovnis
Posts: 12
Joined: 25 Mar 2018, 13:40

Re: Automatically Restore Last Window Position For Each Process

30 Mar 2018, 12:03

Thx for yours explanations.

With your last version :
Notepad++.exe box ("Save file ?") is randomly buged (too much tiny) and there is no position recall at all (at snaping positions).
I don't know how manage explorer.exe. It seems to not to work :

Code: Select all

managedProcesses = Explorer.exe

taskmgr.exe is not recalled very well. It doesn't feet exactly with the screen edges (when it was previously snapped).
When I snap notepad.exe the recall works only with the bottom right and bottom left corners. With the top right or top left corners or right or left cornes, the recall is buged.
Sometimes, Onenote, Skype & co doesn't recall.
Last edited by ovnis on 30 Mar 2018, 16:03, edited 1 time in total.
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: Automatically Restore Last Window Position For Each Process

30 Mar 2018, 15:52

jeka wrote:Playing a bit more with v2, noticed that if I resize-reposition mintty.exe window in the main monitor, the position is remembered/restored. If I move mintty.exe to the secondary, then close and re-open, it opens up in the last position for the main monitor. Is this expected?
EDIT: i updated -v2- post, try it now, let me know how it performs, i can't test it because i have a single monitor, but i removed the constraints that were logically causing the issue.

@ovnis:

Given your issues, i actually installed a win10 VM to test if your problems are accurate, as expected 'Universal Windows Platform Apps' didn't work as they should(OneNote,Mail..), however explorer,task manager & notepad worked with out fault,given their classnames & styles were accurate,& incase of explorer i had to use the 'file.ahk' to manually modify the classname & style for the explorer window,as expressed in my -v2- post,in the 'Known Issues' section. All i can say is check the log file, 'WindowSizePosLog.ini.LOG.log' to debug your issues and use 'file.ahk' to verify the classname & styles info in the ini is accurate.
And i do use Notepad++ to deal with all things text,so i can't account for your issues there,given i have none.

Cheers.
Outsourcing Clicks & Presses Since 2004.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: Spawnova, TheNaviator and 75 guests