This is a more complicated example of what can be done using AutoHotKey. I use this script every day at work and pretty much consider it indispensable when using multiple monitors.
Simply, this script lets you use the keyboard to move windows between monitors. Control-Alt-+ moves the window to the same position on the next monitor to the right, while Control-Alt-— moves the window to the next monitor to the left. Control-Alt-Up can be used to maximize a window across the first two monitors, which comes in really handy when trying to work with multiple Excel workbooks since you can't make it open two instances any more… Overall, I think the code is pretty easy to follow.
01 02 03 04 05 06 07 08 09 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 82 83 84 | SysGet ,MaxMonitor,MonitorCount Menu , Tray , Standard Menu , Tray , Add Menu , Tray , Add ,Increment Window's Monitor Number ,IncrementWindowMonitor Menu , Tray , Add ,Decrement Window's Monitor Number ,DecrementWindowMonitor Menu , Tray , Add , Maximize Window Across First Two Screens,MultiMaximizeWindow return ^!NumpadAdd:: IncrementWindowMonitor: Gosub ,FindCurrentMonitor If (CurrMonitor = 0) return NewMonitor := CurrMonitor + 1 If (NewMonitor <= MaxMonitor) Gosub ,MoveCurrentWindow return ^!NumpadSub:: DecrementWindowMonitor: Gosub ,FindCurrentMonitor If (CurrMonitor = 0) return NewMonitor := CurrMonitor - 1 If (NewMonitor >= 1) Gosub ,MoveCurrentWindow return ^!Up:: MultiMaximizeWindow: WinGet ,WindowState, MinMax ,A SysGet ,LeftMonitor,MonitorWorkArea,1 SysGet ,RightMonitor,Monitor,2 If (WindowState = 1) WinRestore ,A WinMove ,A,,0,0,RightMonitorRight,LeftMonitorBottom return MoveCurrentWindow: WinGet ,WindowState, MinMax ,A SysGet ,NewMonitor,Monitor, %NewMonitor% NewWinX := WinX - MonitorLeft + NewMonitorLeft NewWinY := WinY - MonitorTop + NewMonitorTop If (WindowState = 1) WinRestore ,A WinMove ,A,, %NewWinX% , %NewWinY% If (WindowState = 1) WinMaximize ,A return FindCurrentMonitor: WinGetPos ,WinX,WinY,WinWidth,WinHeight,A MidpointX := WinX + (WinWidth / 2) MidpointY := WinY + (WinWidth / 2) CurrMonitor := 1 Loop %MaxMonitor% { SysGet ,Monitor,Monitor, %CurrMonitor% If (MidpointX >= MonitorLeft AND MidpointX <= MonitorRight AND MidpointY >= MonitorTop AND MidpointY <= MonitorBottom) break CurrMonitor := CurrMonitor + 1 } if (CurrMonitor > MaxMonitor) { MsgBox What just happened?? This window isn't on an active monitor?? CurrMonitor := 0 return } return |