43

I have dual monitors and I want to span my current window so that it appears as one giant window on both monitors. Does anyone know how to do this natively in Windows?

12 Answers 12

16

In contrast with what others are saying, here is a free, working solution that maximises the window which is under the mouse.

(Credits go to the guy who wrote these amazing 'autoit' functions - I just wrote the bit which uses them.)

Download autoit and install it (free software):

http://www.autoitscript.com/site/autoit/

Create a .au3 file.

Paste this inside:

#include <misc.au3>
#include <Array.au3>
HotKeySet('{ESC}', '_Exit')

Global $WinText, $OldMouse[2], $NewMouse[2], $Windows, $x, $MyWin, $MyCoords

$NewMouse = MouseGetPos()
$title = _GetWin()
WinSetState($MyWin,"",@SW_RESTORE)
WinMove($MyWin,"",0,0,3840,1165)

Func _GetWin()
    Local $Coords
    ToolTip("")
    $Mouse = MouseGetPos()
    $OldMouse = $Mouse
    $Windows = _WinList()
    ;_ArrayDisplay($Windows, "")
    For $x = 1 To UBound($Windows)-1
        $Coords = WinGetPos($Windows[$x][0], "")
        If $Coords = -4 Then ExitLoop
        If IsArray($Coords) Then
            If $Mouse[0] >= $Coords[0] And $Mouse[0] <= ($Coords[0]+$Coords[2]) And $Mouse[1] >= $Coords[1] And $Mouse[1] <= ($Coords[1]+$Coords[3]) Then ExitLoop
        EndIf   
    Next
    If $x = UBound($Windows) Then $x -= 1
    $MyWin =  $Windows[$x][0]
    $Control = _MouseGetCtrlInfo()
    $Return = $Windows[$x][0] & @CRLF & $Control 
    Return $Return
EndFunc 

Func _WinList()
    Local $WinListArray[1][2]
    $var = WinList()
    For $i = 1 to $var[0][0]
        If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
            Redim $WinListArray[UBound($WinListArray) + 1][2]
            $WinListArray[UBound($WinListArray)-1][0] = $var[$i][0]
            $WinListArray[UBound($WinListArray)-1][1] = $var[$i][1]
        EndIf
    Next
    Return $WinListArray
EndFunc

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf
EndFunc

Func _Exit()
    Exit
EndFunc 

Func _MouseGetCtrlInfo()  ; get ID, Classe and Text of a control
    Global $hWin = WinGetHandle($MyWin)
    Global $sClassList = WinGetClassList($hWin)
    Local $sSplitClass = StringSplit(StringTrimRight($sClassList, 1), @LF)
    Local $aMPos = MouseGetPos()
    ;_ArrayDisplay($sSplitClass, "")
    $MyCoords = ClientToScreen($hWin)
    For $iCount = UBound($sSplitClass) - 1 To 1 Step - 1
        Local $nCount = 0
        If $sSplitClass[$iCount] = "WorkerW" Then ContinueLoop
        While 1
            $nCount += 1
            $aCPos = ControlGetPos($hWin, '', $sSplitClass[$iCount] & $nCount)
            If @error Then ExitLoop
            $hCtrlWnd = ControlGetHandle ($hWin, "", $sSplitClass[$iCount] & $nCount)
            If IsArray($aCPos) Then
                If $aMPos[0] >= ($MyCoords[0]+$aCPos[0]) And $aMPos[0] <= ($MyCoords[0]+$aCPos[0] + $aCPos[2]) _
                    And $aMPos[1] >= ($MyCoords[1]+$aCPos[1]) And $aMPos[1] <= ($MyCoords[1]+$aCPos[1] + $aCPos[3]) Then
                    $aReturn = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hCtrlWnd)
                    If @error Then Return "Err"
                    $Text = ControlGetText($hWin, '', $sSplitClass[$iCount] & $nCount)
                    If StringInStr($Text, @LF) Then $Text = "demasiado largo"
                    If IsArray($aReturn) Then Return 'ControlID: ' & $aReturn[0] & @CRLF & 'ClassNameNN: ' & $sSplitClass[$iCount] & $nCount &  @CRLF & "Text: " & $Text
                EndIf      
            EndIf
        WEnd
    Next
    ;_ArrayDisplay($sSplitClass, "")
    Return "No Ctrl"
EndFunc

Func ClientToScreen($hWnd)    ; get client area of a win relative to the screan
    Local $Point, $aRes[2]
    Local $cX, $cY
    $Point = DllStructCreate("int;int")
    DllStructSetData($Point, 1, $cX)
    DllStructSetData($Point, 1, $cY)
    DllCall("User32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($Point))
    $aRes[0] = DllStructGetData($Point, 1)
    $aRes[1] = DllStructGetData($Point, 2)
    Return $aRes
EndFunc

Then change the line

WinMove($MyWin,"",0,0,3840,1165)

to the values of your liking.

Then you can create a windows shortcut to this file, right click it->properties, and assign a shortcut (e.g. CTRL+ALT+UP).

Most likely you will find that you will need to repeat the procedure and create a second file to restore the window to a small size.

Hope this helps

  • 1
    Love it! I was going to use the NVidia mosaic, but the monitors I wanted to split across where from two separate graphics cards, and couldn't recable because of KVM not doing VGA. Only gotchya - I wasn't able to get the keyboard shortcut to work directly off a shortcut to the .au3 file. I was able to get a keyboard shortcut to work off a shortcut to a batch script that called the au3 script though. – paquetp Nov 29 '13 at 19:59
  • 1
    Indeed the shortcut method does not work, unless the script file is placed on your desktop. – nikos Dec 1 '13 at 11:39
  • 1
    For those having more than 2 monitors, the 0,0 in the line WinMove($MyWin,"",0,0,3840,1165) represents the coordinates of the starting point, so one may maximise across any amount of screens by changing these numbers accordingly. – ilakast Jul 28 '14 at 13:00
  • I have to create a shortcut to this maximize.au3 in Win 10, and the properties of the shortcut let me assign a key-shortcut; not batch needed. – Martin Zaske Jun 7 '18 at 8:30
  • @nikos this script works for me but I cannot figure out the syntax for the windows position; seems my 0,0 is somewhere "near" the top left of my main monitor but not quite. Also my second monitor is to the left of my main monitor (and the script seems to allow for such, but I do not yet read AutoIt syntax). But the script is opening my program to the right of my main monitor (where there is "nothing"). I tried hooking to a negative value (-1920,0) but that did not work, negative numbers refused. Please advise. Your answer is a joy, will be my solution for many programs, just need to learn more – Martin Zaske Jun 7 '18 at 8:34
8

Use Dual Monitor Tools: it's a set of free tools do manage multiple screens setup.

In the Swap screen tool you can assign a hotkey to the "Supersize active window" so you can maximize it to occupy all the screens.

  • 2
    Excellent program with sane defaults (all disabled) that does exactly what I was looking for, coming from Ultramon. A hint: the hotkey to "Supersize active window" acts like a toggle. Hitting it again restores the window. – Fanis Sep 5 '17 at 14:52
8

Jeff Axelrod has a great solution that uses AutoHotKey.

He maps the Shift + Windows + Up combination to maximize a window across all displays, which compliments Windows 7's Windows + Up hotkey, which maximizes the selected window in one monitor.

Here is his code (thanks Jeff!):

;Shift + Windows + Up (maximize a window across all displays) https://stackoverflow.com/a/9830200/470749
+#Up::
    WinGetActiveTitle, Title
    WinRestore, %Title%
   SysGet, X1, 76
   SysGet, Y1, 77
   SysGet, Width, 78
   SysGet, Height, 79
   WinMove, %Title%,, X1, Y1, Width, Height
return
  • Shift + Windows + Up does not work on my Windows 10 setup with two screens and two different graphics drivers. Still potentially useful to others. – Martin Zaske Jun 7 '18 at 8:11
3

If you have an nVidia video card:

  1. Right-click on the desktop, and click "NVIDIA Control Panel"
  2. At the bottom of the list of tasks, under Workstation, is "Set up Mosaic". Click it.
  3. In the right pane, click the checkbox next to "Enable Mosaic"
  4. Under Displays, put checkmarks next to the monitors you want to combine.
  5. Under Configuration, select what topology you want (side-by-side, vertical..)
  6. At the bottom-right of the screen, click "Apply"

Now, when you click the Maximize button, it'll cover both monitors. Your taskbar will also cover both monitors. If that bugs you, try dragging it to the left of the monitor so it becomes vertical (this works better if you make the icons small and use 'never combine').

2

I use a free utility to do so, VirtualScreenMaximizer:

http://virtualscreenmax.codeplex.com/releases/view/20213

You can customize the shortcuts to use for maximizing and restoring, and it will expand the window over the taskbar when maximizing.

2

A bit late but if using Intel integrated graphics you can open the Intel graphics control panel, select display menu and from there choose multiple displays and choose "Collage" this will let you choose which monitors you would like to extend across along with some other choices.

Here's a screenshot of it enabled:

Heres a screenshot of it enabled

1

Click and drag, otherwise you can use your advanced graphics card to configure the monitors to act as one large screen.

0

On my Windows 7 I'm able to drag the window so that it covers both screens. If you right click your desktop and chose "screen resolution", you have to chose "extend these displays" under "multiple displays". If you close the window again it should remember size and position.

  • That's true, I'm looking for a solution where you can easily maximize the window to both monitors with either a shortcut or something like that. – Crackerjack Sep 9 '10 at 16:57
  • aren't you able to do that by simply dragging the window title-bar to the to the top of the screen – subanki Sep 9 '10 at 17:05
  • @subanki - no, that'll just maximize the window on the current monitor (the one you "bumped") – Chris_K Sep 9 '10 at 20:06
0

If anyone is still trying to do this using autoit I managed do this using this code:

HotKeySet("^+{UP}", "Resize_Window") ; CTRL+SHIFT+UP
While 1
    Sleep(1000)
WEnd
Func Resize_Window()
    WinSetState("[ACTIVE]","",@SW_RESTORE)
    WinMove("[ACTIVE]","",0,0,_WinAPI_GetSystemMetrics($SM_CXVIRTUALSCREEN),_WinAPI_GetSystemMetrics($SM_CYVIRTUALSCREEN))
EndFunc
  • After including WinAPI.au3 and WindowsConstants.au3 this works. – Max Hohenegger Feb 23 '16 at 10:38
0

I use this workaround with Sizer (homepage) - its small freeware utility allows you to set predefined windows size by right-click in Window stretch area.

Just create profile set:

  • Width = sum of monitors widths
  • Height = Monitor height - taskbar height (= 40)
  • Move to = Top left.

Then just right click to right-bottom end of the Window and select the profile.

enter image description here

0

I found a way to do this without any software or code. It isn't automatic or perfect, but is easy and works well enough.

  1. Windows + left or right arrow key to snap the window to half a monitor on the far edge of the two monitors
  2. Grab the edge of the window and drag it across both monitors to the far side
0

Right click on toolbar of windows, select Restore, then resize it on both screens.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.