Skip to content

Commit

Permalink
refactor: VD.MoveWindowToRelativeDesktopNum("A", -1).follow() ; #80
Browse files Browse the repository at this point in the history
  • Loading branch information
FuPeiJiang committed Dec 21, 2024
1 parent 0fac893 commit 6048a99
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ if you don't want VD switching animation, set `VD.animation_on:=false`
* <kbd>Numpad6</kbd> to move the active window to `Desktop 3`<br>
* here, I choose to follow the window
```autohotkey
numpad4::VD.MoveWindowToDesktopNum("A",1), VD.goToDesktopNum(1)
numpad5::VD.MoveWindowToDesktopNum("A",2), VD.goToDesktopNum(2)
numpad6::VD.MoveWindowToDesktopNum("A",3), VD.goToDesktopNum(3)
numpad4::VD.MoveWindowToDesktopNum("A",1).follow()
numpad5::VD.MoveWindowToDesktopNum("A",2).follow()
numpad6::VD.MoveWindowToDesktopNum("A",3).follow()
```
```autohotkey
numpad7::VD.MoveWindowToDesktopNum("A",1)
Expand All @@ -43,9 +43,9 @@ numpad9::VD.MoveWindowToDesktopNum("A",3)
^#right::VD.goToRelativeDesktopNum(+1)
; move window to left and follow it
#!left::VD.goToDesktopNum(VD.MoveWindowToRelativeDesktopNum("A", -1))
#!left::VD.MoveWindowToRelativeDesktopNum("A", -1).follow()
; move window to right and follow it
#!right::VD.goToDesktopNum(VD.MoveWindowToRelativeDesktopNum("A", 1))
#!right::VD.MoveWindowToRelativeDesktopNum("A", 1).follow()
```

you can remap everything
Expand Down Expand Up @@ -99,8 +99,6 @@ Loop %id%
MsgBox % foundProcesses
```

<!-- Desktop2`nPress Numpad6 to move the active window to Desktop3 and go to Desktop 3 (follow the window) -->

## cool fixes:<br>
* Switching VD does not make icons (on the taskbar) flash<br>
https://github.com/mzomparelli/zVirtualDesktop/issues/59#issue-227209226
Expand Down
10 changes: 5 additions & 5 deletions VD examples.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ numpad2::VD.goToDesktopNum(2)
numpad3::VD.goToDesktopNum(3)

;follow your window
numpad4::VD.MoveWindowToDesktopNum("A",1), VD.goToDesktopNum(1)
numpad5::VD.MoveWindowToDesktopNum("A",2), VD.goToDesktopNum(2)
numpad6::VD.MoveWindowToDesktopNum("A",3), VD.goToDesktopNum(3)
numpad4::VD.MoveWindowToDesktopNum("A",1).follow()
numpad5::VD.MoveWindowToDesktopNum("A",2).follow()
numpad6::VD.MoveWindowToDesktopNum("A",3).follow()

;just move window
numpad7::VD.MoveWindowToDesktopNum("A",1)
Expand All @@ -88,9 +88,9 @@ numpad9::VD.MoveWindowToDesktopNum("A",3)
^+#right::VD.goToRelativeDesktopNum(+1)

; move window to left and follow it
#!left::VD.goToDesktopNum(VD.MoveWindowToRelativeDesktopNum("A", -1))
#!left::VD.MoveWindowToRelativeDesktopNum("A", -1).follow()
; move window to right and follow it
#!right::VD.goToDesktopNum(VD.MoveWindowToRelativeDesktopNum("A", 1))
#!right::VD.MoveWindowToRelativeDesktopNum("A", 1).follow()

;to come back to this window
#NumpadMult:: ;#*
Expand Down
16 changes: 13 additions & 3 deletions VD.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,18 @@ class VD {
this.SetForegroundWindow(firstWindowId)
}

return new this.WindowInfo(theHwnd, desktopNum)
}

class WindowInfo {
__New(hwnd, desktopNum) {
this.hwnd:=hwnd
this.desktopNum:=desktopNum
}
follow() {
VD.goToDesktopNum(this.desktopNum)
WinActivate % "ahk_id " this.hwnd
}
}

getRelativeDesktopNum(anchor_desktopNum, relative_count) {
Expand All @@ -716,9 +728,7 @@ class VD {
desktopNum_ofWindow := this.getDesktopNumOfWindow(wintitle)
absolute_desktopNum := this.getRelativeDesktopNum(desktopNum_ofWindow, relative_count)

this.MoveWindowToDesktopNum(wintitle, absolute_desktopNum)

return absolute_desktopNum
return this.MoveWindowToDesktopNum(wintitle, absolute_desktopNum)
}

gotoRelativeDesktopNum(relative_count) {
Expand Down

0 comments on commit 6048a99

Please sign in to comment.