-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathVD-move-window-with-desktop.ahk
53 lines (42 loc) · 1.62 KB
/
VD-move-window-with-desktop.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
;FROM https://superuser.com/questions/1685845/moving-current-window-to-another-desktop-in-windows-11-using-shortcut-keys
;#SETUP START
#SingleInstance force
ListLines 0
SendMode "Input" ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir A_ScriptDir ; Ensures a consistent starting directory.
KeyHistory 0
#WinActivateForce
ProcessSetPriority "H"
SetWinDelay -1
SetControlDelay -1
; Include the library
#Include ../VD.ahk/VD.ah2
; VD.init() ; COMMENT OUT `static dummyStatic1 := VD.init()` if you don't want to init at start of script
; You should WinHide invisible programs that have a window.
try {
WinHide "Malwarebytes Tray Application"
} catch {
}
;#SETUP END
VD.createUntil(3) ; Create until we have at least 3 virtual desktops
return
^#+Left:: {
currentDesktop := VD.getCurrentDesktopNum()
totalDesktops := VD.getCount()
; Loop around to the last desktop if at the first one
previousDesktop := (currentDesktop = 1) ? totalDesktops : currentDesktop - 1
activeWindow := WinExist("A")
VD.goToDesktopNum(previousDesktop)
VD.MoveWindowToDesktopNum("ahk_id " activeWindow, previousDesktop)
WinActivate("ahk_id " activeWindow) ; Once in a while it's not active
}
^#+Right:: {
currentDesktop := VD.getCurrentDesktopNum()
totalDesktops := VD.getCount()
; Loop around to the first desktop if at the last one
nextDesktop := (currentDesktop = totalDesktops) ? 1 : currentDesktop + 1
activeWindow := WinExist("A")
VD.goToDesktopNum(nextDesktop)
VD.MoveWindowToDesktopNum("ahk_id " activeWindow, nextDesktop)
WinActivate("ahk_id " activeWindow)
}