Hi There,
I know this thread is ancient, however I was looking for a script that switched windows between monitors and this was the first one I found

.
After trying it out, I found it didn't quite do what I was after -- mainly because my monitors don't run at the same resolutions. Hence I've changed it slightly so that instead of just blindly swapping the windows between the monitors, it now swaps but maintains the relative size of the window based upon the size of the new monitor. This means that when full-screen windows are switched between the different monitors they still appear full screen when switched to a larger monitor, and don't grow outside the side of the monitor when switched to a smaller one.
The modified script is below:
Code:
; MonSwap - Swaps all the application windows from one monitor to another.
; v1.0.1
; Author: Alan Henager
;
; v1.0.1 - xenrik - Updated to use relative screen size when swapping
SetWinDelay, 0 ; This switching should be instant
; Set this key combination to whatever.
+#s::
SwapAll:
{
DetectHiddenWindows, Off ; I think this is default, but just for safety's sake...
WinGet, WinArray, List ; , , , Sharp
; Enable the above commented out portion if you are running SharpE
i := WinArray
Loop, %i% {
WinID := WinArray%A_Index%
WinGetTitle, CurWin, ahk_id %WinID%
If (CurWin = ) ; For some reason, CurWin <> didn't seem to work.
{}
else
{
WinGet, IsMin, MinMax, ahk_id %WinID% ; The window will re-locate even if it's minimized
If (IsMin = -1) {
WinRestore, ahk_id %WinID%
SwapMon(WinID)
WinMinimize, ahk_id %WinID%
} else {
SwapMon(WinID)
}
}
}
return
}
SwapMon(WinID) ; Swaps window with and ID of WinID onto the other monitor
{
SysGet, Mon1, Monitor, 1
Mon1Width := Mon1Right - Mon1Left
Mon1Height := Mon1Bottom - Mon1Top
SysGet, Mon2, Monitor, 2
Mon2Width := Mon2Right - Mon2Left
Mon2Height := Mon2Bottom - Mon2Top
WinGetPos, WinX, WinY, WinWidth, WinHeight, ahk_id %WinID%
WinCenter := WinX + (WinWidth / 2)
if (WinCenter >= Mon1Left and WinCenter <= Mon1Right) {
NewX := (WinX - Mon1Left) / Mon1Width
NewX := Mon2Left + (Mon2Width * NewX)
NewWidth := WinWidth / Mon1Width
NewWidth := Mon2Width * NewWidth
NewY := (WinY - Mon1Top) / Mon1Height
NewY := Mon2Top + (Mon2Height * NewY)
NewHeight := WinHeight / Mon1Height
NewHeight := Mon2Height * NewHeight
} else {
NewX := (WinX - Mon2Left) / Mon2Width
NewX := Mon1Left + (Mon1Width * NewX)
NewWidth := WinWidth / Mon2Width
NewWidth := Mon1Width * NewWidth
NewY := (WinY - Mon2Top) / Mon2Height
NewY := Mon1Top + (Mon1Height * NewY)
NewHeight := WinHeight / Mon2Height
NewHeight := Mon1Height * NewHeight
}
WinMove, ahk_id %WinID%, , %NewX%, %NewY%, %NewWidth%, %NewHeight%
return
}