Jump to content

[Help] Put windows next to other other?


kdot
 Share

Recommended Posts

Have a look at the WinMove function.

WinMove ( "title", "text", x, y [, width [, height [, speed]]] )

 

Link to comment
Share on other sites

It's a function.  You set the x and y when you write the command.  You can base the x,y, w, and h based on the previous window's x,y,w,and h.  You can get that info using the WinGetPos function.

Edited by TheXman
Link to comment
Share on other sites

The WinMove command has 4 required parameters.

WinMove ( "title", "text", x, y [, width [, height [, speed]]] )

Also, if you have multiple windows with the same title, you will probably want to use the INSTANCE property of the advanced window description title.

Refer to: https://www.autoitscript.com/autoit3/docs/intro/windowsadvanced.htm

 

Edited by TheXman
Link to comment
Share on other sites

2 minutes ago, kdot said:

I don't need to set the width or height I only need to move each window. 

The command has 4 required parameters: title, text, x and y.  If you aren't using the text parameter, then use "".

 

The help file examples are very useful.

Edited by TheXman
Link to comment
Share on other sites

Here's a very simple example using notepad windows.

#include <Array.au3>

;Launch 4 notepad windows
Run("notepad.exe")
Run("notepad.exe")
Run("notepad.exe")
Run("notepad.exe")

;Wait a couple of seconds for the windows to load
Sleep(2000)

;Get a list of the window handles
Local $aWinList = WinList("Untitled - Notepad")
_ArrayDisplay($aWinList)

;Resize and move windows
WinMove($aWinList[1][1], "",   0,   0, 200, 200)
WinMove($aWinList[2][1], "", 200,   0, 200, 200)
WinMove($aWinList[3][1], "",   0, 200, 200, 200)
WinMove($aWinList[4][1], "", 200, 200, 200, 200)

Since I'm not sure how new to AutoIt you are, when you see the display of the array, close it, and the script will continue.

Edited by TheXman
Link to comment
Share on other sites

On 2/19/2018 at 10:13 PM, TheXman said:

Here's a very simple example using notepad windows.

#include <Array.au3>

;Launch 4 notepad windows
Run("notepad.exe")
Run("notepad.exe")
Run("notepad.exe")
Run("notepad.exe")

;Wait a couple of seconds for the windows to load
Sleep(2000)

;Get a list of the window handles
Local $aWinList = WinList("Untitled - Notepad")
_ArrayDisplay($aWinList)

;Resize and move windows
WinMove($aWinList[1][1], "",   0,   0, 200, 200)
WinMove($aWinList[2][1], "", 200,   0, 200, 200)
WinMove($aWinList[3][1], "",   0, 200, 200, 200)
WinMove($aWinList[4][1], "", 200, 200, 200, 200)

Since I'm not sure how new to AutoIt you are, when you see the display of the array, close it, and the script will continue.

Is it possible to do something more advanced like grab the current resolution and move each window to fill the entire monitor? 

Link to comment
Share on other sites

50 minutes ago, kdot said:

Is it possible to do something more advanced like grab the current resolution and move each window to fill the entire monitor? 

Yes, that's possible.

You can get the monitor resolution and workable area info by using the _WinAPI_GetMonitorInfo function.  Then, it's just a matter of calculation the window size and positions.

Edited by TheXman
Link to comment
Share on other sites

The example below should give you a decent starting point.  I left out some of the fun parts like getting the monitor's resolution and calculating what your width and height should be.   I mean, why should I have all of the fun, right?  ;)

 

#include <Array.au3>

example()

Func example()
    Const $kWIDTH  = 250
    Const $kHEIGHT = 300

    Local $aWinList
    Local $iRow, $iCol, $iIndex, $iX, $iY

    ;Launch 10 notepad windows
    For $i = 1 To 10
        Run("notepad.exe")
    Next

    ;Wait a couple of seconds for the windows to load
    Sleep(2000)

    ;Get a list of the window handles
    $aWinList = WinList("Untitled - Notepad")
;~  _ArrayDisplay($aWinList)

    ;Display 2 x 5 array of windows
    $iIndex = 0
    For $iRow = 0 To 1
        For $iCol = 0 To 4
            ;Resize and move windows into place
            $iIndex += 1
            $iX      = $iCol * $kWIDTH
            $iY      = $iRow * $kHEIGHT
            WinMove($aWinList[$iIndex][1], "", $iX, $iY, $kWIDTH, $kHEIGHT)
        Next
    Next
EndFunc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...