Skip to content

Commit

Permalink
🐛 fix bug of desktop.ah2 not working
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCrether committed Oct 16, 2023
1 parent afa5fd1 commit d1e5495
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions desktop.ah2
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ MoveWinToDesktopNumberProc := GetProc("MoveWindowToDesktopNumber")
RegisterPostMessageHookProc := GetProc("RegisterPostMessageHook")
UnregisterPostMessageHookProc := GetProc("UnregisterPostMessageHook")
IsPinnedProc := GetProc("IsPinnedWindow")
; RestartDesktopDLLProc := GetProc("RestartVirtualDesktopAccessor")
GetWinDesktopNumberProc := GetProc("GetWindowDesktopNumber")
GetDesktopCountProc := GetProc("GetDesktopCount")
activeWindowByDesktop := Map()
Expand All @@ -54,7 +53,6 @@ MoveWindowToDesktop(hwnd, number, moveWith := false) {
DllCall(MoveWinToDesktopNumberProc, "UInt", hwnd, "UInt", number)
if (moveWith) {
GoToDesktopNumber(number)
; DllCall(GoToDesktopNumberProc, UInt, number)
}

WinActivate("ahk_class Shell_TrayWnd")
Expand All @@ -67,7 +65,6 @@ MoveCurrentWindowToDesktop(number, moveWith := false) {
try {
activeHwnd := WinGetID("A")
activeWindowByDesktop[number] := activeHwnd ; Do not activate

MoveWindowToDesktop(activeHwnd, number, moveWith)
}
}
Expand All @@ -76,18 +73,15 @@ GoToDesktopNumber(num) {
global GetCurrentDesktopNumberProc, GoToDesktopNumberProc, IsPinnedProc, activeWindowByDesktop

; Store the active window of old desktop, if it is not pinned
try {
activeHwnd := WinGetID("A")
activeWindowByDesktop[current] := activeHwnd
}
current := DllCall(GetCurrentDesktopNumberProc, "UInt")
activeHwnd := WinGetID("A")
activeWindowByDesktop[current] := activeHwnd

; stop if the desktop is already active
if (current == num) {
return
}


; Try to avoid flashing task bar buttons, deactivate the current window if it is not pinned
isPinned := 0
try {
Expand Down Expand Up @@ -118,9 +112,10 @@ VWMess(wParam, lParam, msg, hwnd) { ; wParam is the old desktop and lParam is th
GenerateDynamicHotkeys()
}

; no reason to try to focus any window if the desktop stayed the same
if (wParam == lParam) {
return
} ; no reason to try to focus any window if the desktop stayed the same
}
if (lParam == "__Item") {
lParam := DllCall(GetCurrentDesktopNumberProc, "Int")
}
Expand Down

0 comments on commit d1e5495

Please sign in to comment.