phazei / Win11AutoHotKeyFixes

This is to resolve deficiencies of Win11 window management, specifically moving active window to next desktop and cascading/tiling windows
MIT License
27 stars 4 forks source link

Support for wrapping/cycling through virtual desktops when moving windows with hotkeys #1

Open laklare opened 1 year ago

laklare commented 1 year ago

VD.ahk has functions for relative desktop positions so I modified your code slightly to support wrapping left or right when moving windows between desktops using these hotkeys.

^#+Left::
    r := -1
    n := VD.getCurrentDesktopNum()
    m := VD.getRelativeDesktopNum(n, r)
    n = n+r
    active := "ahk_id" WinExist("A")
    VD.MoveWindowToDesktopNum(active,m), VD.goToRelativeDesktopNum(r)
    WinActivate active ;once in a while it's not active
Return

^#+Right::
    r := 1
    n := VD.getCurrentDesktopNum()
    m := VD.getRelativeDesktopNum(n, r)
    n = n+r
    active := "ahk_id" WinExist("A")
    VD.MoveWindowToDesktopNum(active,m), VD.goToRelativeDesktopNum(r)
    WinActivate active ;once in a while it's not active
Return

; wrapping / cycle back to first desktop when at the last
^#left::VD.goToRelativeDesktopNum(-1)
^#right::VD.goToRelativeDesktopNum(+1)