[bugfix] performance / wechat got ignored

This commit is contained in:
Klesh Wong 2021-07-06 10:40:42 +08:00
parent 1eba0df573
commit 92cac7824b

View File

@ -14,7 +14,8 @@ global ARRANGEMENT := Object()
global ARRANGEMENT_PATH := A_AppData . "\arrangement.json" global ARRANGEMENT_PATH := A_AppData . "\arrangement.json"
global PADDING := 10 global PADDING := 10
LoadArrangement() LoadArrangement()
WatchNewWindow() ;WatchNewWindow()
SetTimer, AdjustNewWindow, 1000
; ========================= ; =========================
; BINDINGS ; BINDINGS
; ========================= ; =========================
@ -198,7 +199,6 @@ MoveActiveWinByDirection(direction) {
SaveActiveWindowDirection(direction) SaveActiveWindowDirection(direction)
} }
SaveArrangement() { SaveArrangement() {
global ARRANGEMENT global ARRANGEMENT
global ARRANGEMENT_PATH global ARRANGEMENT_PATH
@ -253,7 +253,20 @@ UnignoreArrangementForActiveWindow() {
SaveArrangement() SaveArrangement()
} }
IsActiveWindowIgnore() { IsActiveWindowBorderless() {
WinGet s, Style, A
if (not s & +0xC00000) {
return true
}
return false
}
IsActiveWindowSizeboxed() {
WinGet, s, Style, A
return s & 0x40000
}
IsActiveWindowIgnored() {
global ARRANGEMENT global ARRANGEMENT
if (ARRANGEMENT["ignore"].HasKey(GetActiveWindowClassPath())) { if (ARRANGEMENT["ignore"].HasKey(GetActiveWindowClassPath())) {
return true return true
@ -262,8 +275,7 @@ IsActiveWindowIgnore() {
; if (title = "") { ; if (title = "") {
; return true ; return true
; } ; }
WinGet s, Style, A if (not IsActiveWindowSizeboxed()) {
if (not s & +0xC00000) {
return true return true
} }
return false return false
@ -276,20 +288,28 @@ SaveActiveWindowDirection(direction) {
SaveArrangement() SaveArrangement()
} }
WatchNewWindow() { ActiveWinInfo() {
global ARRANGEMENT WinGetTitle, title, A
Loop { WinGetClass, klass, A
WinWaitActive A ; makes the active window to be the Last Found WinGet processPath, ProcessPath, A
if not IsActiveWindowSeen() and not IsActiveWindowIgnore() { return processPath . " " . klass . " " . title
classPath := GetActiveWindowClassPath()
if ARRANGEMENT["windows"].HasKey(classPath) {
MoveActiveWinByDirection(ARRANGEMENT["windows"][classPath])
}
}
WinWaitNotActive ; waits until the active window changes
}
} }
AdjustNewWindow() {
global log
seen := IsActiveWindowSeen()
ignored := IsActiveWindowIgnored()
wininfo := ActiveWinInfo()
if not seen {
LogDebug(Format("win: {1}, seen: {2}, ignore: {3}", wininfo, seen, ignored))
}
if not seen and not ignored {
classPath := GetActiveWindowClassPath()
if ARRANGEMENT["windows"].HasKey(classPath) {
MoveActiveWinByDirection(ARRANGEMENT["windows"][classPath])
}
}
}
ToggleActiveWinMaximum() { ToggleActiveWinMaximum() {
WinGet, isMax, MinMax, A WinGet, isMax, MinMax, A
@ -311,13 +331,17 @@ GetSelectedText() {
} }
ShowDebug() { ShowDebug() {
WinGet, s, Style, A ShowObject(IsActiveWindowSizeboxed())
if (s & +0xC00000) {
SoundBeep, 750, 200
}
} }
ShowObject(obj) { ShowObject(obj) {
msg := JSON.Dump(obj) msg := JSON.Dump(obj)
MsgBox, %msg% MsgBox, %msg%
}
LogDebug(msg) {
FormatTIme, now, , MM-dd HH:mm:ss
log := FileOpen("d:\win.ahk.log", "a")
log.WriteLine(Format("[{1}] {2}", now, msg))
log.Close()
} }