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
2This is still a problem in windows 10! I have 3 monitors and I only use one 'here and there'... when I do, then stop using it, some open programs default to opening up on it. I have to do the win+left arrow to eventually get it back to the main monitor. – None – 2016-06-04T15:13:05.053
1Still a problem seven years later... – Jack Wasey – 2017-02-15T22:30:30.840
Possible duplicate of https://superuser.com/questions/1206086/win8-1-program-thinks-it-is-on-a-phantom-monitor-moves-out-of-view-when-invok
– SDsolar – 2017-05-04T23:18:17.507winlister is the best.. I tried the other tricks before, but this one works all of the time.. alt-space, etc. only works on some windows – Mikey – 2020-02-24T13:43:52.853