Win11AutoHotKeyFixes
Win11AutoHotKeyFixes copied to clipboard
Support for wrapping/cycling through virtual desktops when moving windows with hotkeys
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)