From 75619d06835c3eba8675c7c9852d9ff790028cc2 Mon Sep 17 00:00:00 2001 From: Ven0m0 <82972344+Ven0m0@users.noreply.github.com> Date: Sun, 1 Mar 2026 06:34:25 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20debounce=20window=20pos=20IniWrites?= =?UTF-8?q?=20to=20reduce=20IO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Implemented a `PendingWrites` map with disabled CaseSense. * Initialized a 1000ms `SetTimer` to run `ProcessPendingWrites`. * Modified `SaveCurrentWindowPosition` to defer IniWrite calls to memory instead of writing directly to disk, dramatically reducing I/O usage during drag/resize events. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- ahk/GUI/WM.ahk | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/ahk/GUI/WM.ahk b/ahk/GUI/WM.ahk index 794d376..5979a0a 100644 --- a/ahk/GUI/WM.ahk +++ b/ahk/GUI/WM.ahk @@ -19,6 +19,9 @@ ProcessSetPriority("Normal") MatchList := "" ExclusionList := ["ShellExperienceHost.exe", "SearchUI.exe"] LastSaved := Map() ; Cache for last saved positions to avoid redundant INI writes +LastSaved.CaseSense := "Off" +PendingWrites := Map() +PendingWrites.CaseSense := "Off" ; Build initial list of windows try { @@ -33,6 +36,7 @@ try { ; Main loop - monitor windows and save/restore positions SetTimer(MonitorWindows, 350) +SetTimer(ProcessPendingWrites, 1000) MonitorWindows() { global MatchList, ExclusionList, LastSaved @@ -76,7 +80,7 @@ MonitorWindows() { } SaveCurrentWindowPosition() { - global ExclusionList, LastSaved + global ExclusionList, LastSaved, PendingWrites try { WinGetPos(&X, &Y, &Width, &Height, "A") @@ -102,9 +106,27 @@ SaveCurrentWindowPosition() { ; Only write if position/size changed currentValue := X . "," . Y . "," . Width . "," . Height if (!LastSaved.Has(active_ProcessName) || LastSaved[active_ProcessName] != currentValue) { - IniWrite(currentValue, A_ScriptDir . "\WindowSizePosLog.ini", "Process Names", active_ProcessName) LastSaved[active_ProcessName] := currentValue + PendingWrites[active_ProcessName] := A_TickCount } } } } + +ProcessPendingWrites() { + global PendingWrites, LastSaved + currentTime := A_TickCount + keysToDelete := [] + for processName, lastChangeTime in PendingWrites { + if (currentTime - lastChangeTime >= 1000) { + if (LastSaved.Has(processName)) { + currentValue := LastSaved[processName] + IniWrite(currentValue, A_ScriptDir . "\WindowSizePosLog.ini", "Process Names", processName) + } + keysToDelete.Push(processName) + } + } + for key in keysToDelete { + PendingWrites.Delete(key) + } +}