From Move a window to the bottom/top monitor with a shortcut on Windows by Tymric:
I wrote an AHK script.
Usage:
Win + Alt + Arrow: Move the active window to the monitor whose direction is indicated by the arrow. Note that this may cause your window to move outside the screen if you try to go up from monitor 2 or right from monitor 3 in your setup. I'll update it in the future.
Win + Alt + Number: Move the active window to the given monitor number
#Persistent
SysGet, MonitorCount, MonitorCount
#!Up::
GoSub CalculateDisplacement
WinMove, A, , %xPos%, %displaceYneg%
return
#!Down::
GoSub CalculateDisplacement
WinMove, A, , %xPos%, %displaceYpos%
return
#!Left::
GoSub CalculateDisplacement
WinMove, A, , %displaceXneg%, %yPos%
return
#!Right::
GoSub CalculateDisplacement
WinMove, A, , %displaceXpos%, %yPos%
return
#!1::
GoSub CalculateDisplacement
WinMove, A, , %xPosOn1%, %yPosOn1%
return
#!2::
if (MonitorCount > 1) {
GoSub CalculateDisplacement
WinMove, A, , %xPosOn2%, %yPosOn2%
}
return
#!3::
if (MonitorCount > 2) {
GoSub CalculateDisplacement
WinMove, A, , %xPosOn3%, %yPosOn3%
}
return
#!4::
if (MonitorCount > 3) {
GoSub CalculateDisplacement
WinMove, A, , %xPosOn4%, %yPosOn4%
}
return
#!5::
if (MonitorCount > 4) {
GoSub CalculateDisplacement
WinMove, A, , %xPosOn5%, %yPosOn5%
}
return
#!6::
if (MonitorCount > 5) {
GoSub CalculateDisplacement
WinMove, A, , %xPosOn6%, %yPosOn6%
}
return
#!7::
if (MonitorCount > 6) {
GoSub CalculateDisplacement
WinMove, A, , %xPosOn7%, %yPosOn7%
}
return
#!8::
if (MonitorCount > 7) {
GoSub CalculateDisplacement
WinMove, A, , %xPosOn8%, %yPosOn8%
}
return
#!9::
if (MonitorCount > 8) {
GoSub CalculateDisplacement
WinMove, A, , %xPosOn9%, %yPosOn9%
}
return
CalculateDisplacement:
WinGetPos, xPos, yPos, , , A
Loop, %MonitorCount% {
SysGet, MonitorDimension, Monitor, %A_Index%
if (xPos > MonitorDimensionLeft and xPos < MonitorDimensionRight and yPos < MonitorDimensionBottom and yPos > MonitorDimensionTop) {
currentMonitor = %A_Index%
}
}
SysGet, thisMonitor, Monitor, %currentMonitor%
displaceXpos := xPos + thisMonitorRight - thisMonitorLeft
displaceYpos := yPos + thisMonitorTop - thisMonitorBottom
displaceXneg := xPos - thisMonitorRight + thisMonitorLeft
displaceYneg := yPos - thisMonitorTop + thisMonitorBottom
Loop, %MonitorCount% {
SysGet, nextMonitor, Monitor, %A_Index%
xPosOn%A_Index% := xPos - thisMonitorLeft + nextMonitorLeft
yPosOn%A_Index% := yPos - thisMonitorTop + nextMonitorTop
}
return