-
Notifications
You must be signed in to change notification settings - Fork 22
/
windowMover.ahk
81 lines (73 loc) · 2.01 KB
/
windowMover.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class JPGIncWindowMoverClass
{
moveActiveWindowToDesktopFunctionName := "moveActiveWindowToDesktop"
moveToNextFunctionName := "moveActiveWindowToNextDesktop"
moveToPreviousFunctionName := "moveActiveWindowToPreviousDesktop"
postMoveWindowFunctionName := ""
followToNewDesktop := false
__new()
{
this.dllWindowMover := new JPGIncDllWindowMover()
this.desktopMapper := new DesktopMapperClass(new VirtualDesktopManagerClass())
this.monitorMapper := new MonitorMapperClass()
this._desktopChanger := new JPGIncDesktopChangerClass()
return this
}
doPostMoveWindow()
{
callFunction(this.postMoveWindowFunctionName)
return this
}
moveActiveWindowToDesktop(targetDesktop, follow := false)
{
if(targetDesktop < 1)
{
return this
}
activeHwnd := WinExist("A")
currentDesktop := this.desktopMapper.getDesktopNumber()
if(this.dllWindowMover.isAvailable())
{
this.dllWindowMover.moveActiveWindowToDesktop(targetDesktop)
if(this.followToNewDesktop)
{
activateWindow := false ; we will reactivate the window ourselves
this._desktopChanger.goToDesktop(targetDesktop, activateWindow)
this._reactivateWindow(activeHwnd)
}
} else
{
winhide, % "ahk_id " activeHwnd
this._desktopChanger.goToDesktop(targetDesktop)
WinActivate, ahk_class Shell_TrayWnd
sleep 50
winshow, % "ahk_id " activeHwnd
if(! this.followToNewDesktop)
{
this._desktopChanger.goToDesktop(currentDesktop)
}
}
return this
}
moveActiveWindowToNextDesktop(follow := false)
{
currentDesktop := this.desktopMapper.getDesktopNumber()
return this.moveActiveWindowToDesktop(currentDesktop + 1, follow)
}
moveActiveWindowToPreviousDesktop(follow := false)
{
currentDesktop := this.desktopMapper.getDesktopNumber()
if(currentDesktop == 1)
{
return this
}
return this.moveActiveWindowToDesktop(currentDesktop - 1, follow)
}
_reactivateWindow(activeHwnd)
{
WinActivate, ahk_class Shell_TrayWnd
sleep 50
WinActivate, % "ahk_id " activeHwnd
return this
}
}