[bugfix] auto arrangement not working

This commit is contained in:
Klesh Wong 2021-07-08 21:36:12 +08:00
parent 656fb92446
commit 91b4eda18f
2 changed files with 7 additions and 6 deletions

View File

@ -113,14 +113,14 @@ MoveActiveWinByDirection(direction) {
wy := wy + PADDING wy := wy + PADDING
wh := wh - PADDING * 2 wh := wh - PADDING * 2
WinMove, A,, wx - l, wy - t, ww + l + r, wh + t + b WinMove, A,, wx - l, wy - t, ww + l + r, wh + t + b
LogDebug(Format("move {1} to {2}", activeWinId, direction)) LogDebug("move {1} to {2}", activeWinId, direction)
SaveActiveWindowDirection(direction) SaveActiveWindowDirection(direction)
} }
SaveArrangement() { SaveArrangement() {
LogDebug("SaveArrangement start")
global ARRANGEMENT global ARRANGEMENT
global ARRANGEMENT_PATH global ARRANGEMENT_PATH
LogDebug("SaveArrangement to {1} start", ARRANGEMENT_PATH)
file := FileOpen(ARRANGEMENT_PATH, "w") file := FileOpen(ARRANGEMENT_PATH, "w")
file.Write(JSON.Dump(ARRANGEMENT,, 2)) file.Write(JSON.Dump(ARRANGEMENT,, 2))
file.Close() file.Close()
@ -130,7 +130,7 @@ SaveArrangement() {
LoadArrangement() { LoadArrangement() {
global ARRANGEMENT global ARRANGEMENT
global ARRANGEMENT_PATH global ARRANGEMENT_PATH
LogDebug("LoadArrangement start " .ARRANGEMENT_PATH) LogDebug("LoadArrangement start {1}", ARRANGEMENT_PATH)
try { try {
FileRead, temp, %ARRANGEMENT_PATH% FileRead, temp, %ARRANGEMENT_PATH%
ARRANGEMENT := JSON.Load(temp) ARRANGEMENT := JSON.Load(temp)
@ -232,11 +232,12 @@ ActiveWinInfo() {
} }
AdjustNewWindow() { AdjustNewWindow() {
global ARRANGEMENT
seen := IsActiveWindowSeen() seen := IsActiveWindowSeen()
arrangable := IsActiveWindowArrangable() arrangable := IsActiveWindowArrangable()
wininfo := ActiveWinInfo() wininfo := ActiveWinInfo()
if not seen { if not seen {
LogDebug(Format("win: {1}, seen: {2}, arrangable: {3}", wininfo, seen, arrangable)) LogDebug("win: {1}, seen: {2}, arrangable: {3}", wininfo, seen, arrangable)
} }
if not seen and arrangable { if not seen and arrangable {
windowPath := GetActiveWindowPath() windowPath := GetActiveWindowPath()

View File

@ -14,14 +14,14 @@ ToggleDebugging() {
DEBUGGING := not DEBUGGING DEBUGGING := not DEBUGGING
} }
LogDebug(msg) { LogDebug(params*) {
global DEBUGGING global DEBUGGING
if (not DEBUGGING) { if (not DEBUGGING) {
return return
} }
FormatTIme, now, , MM-dd HH:mm:ss FormatTIme, now, , MM-dd HH:mm:ss
log := FileOpen("d:\win.ahk.log", "a") log := FileOpen("d:\win.ahk.log", "a")
log.WriteLine(Format("[{1}] {2}", now, msg)) log.WriteLine(Format("[{1}] {2}", now, Format(params*)))
log.Close() log.Close()
} }