Foreword: If you are one those not been using the Tile / Cascade facility available in the taskbar, then try it now.Minimize all windows and open two instances of windows explorer. Right-click on an empty area on the Taskbar and select Tile Windows Horizontally.. See the result!... Close those windows! This topic is about doing it from a script.

hwndParent : [in] Handle to the parent window. If this parameter is NULL, the desktop window is assumed.

wHow : [in] Specifies tiling flags. This parameter can be one of the following valuesÂ—optionally combined with MDITILE_SKIPDISABLED to prevent disabled multiple-document interface (MDI) child windows from being tiled. MDITILE_HORIZONTAL Tiles windows horizontally.MDITILE_VERTICAL Tiles windows vertically.lpRect : [in] Pointer to a RECT structure that specifies the rectangular area, in client coordinates, within which the windows are arranged. If this parameter is NULL, the client area of the parent window is used.

cKids : [in] Specifies the number of elements in the array specified by the lpKids parameter. This parameter is ignored if lpKids is NULL.

lpKids : [in] Pointer to an array of handles to the child windows to arrange. If this parameter is NULL, all child windows of the specified parent window (or of the desktop window) are arranged. Return Value

If the function succeeds, the return value is the number of windows arranged.If the function fails, the return value is zero. To get extended error information, call GetLastError.[/list]Remarks : Calling TileWindows causes all maximized windows to be restored to their previous size.

The CascadeWindows function cascades the specified child windows of the specified parent window.

WORD CascadeWindows( HWND hwndParent, UINT wHow, const RECT *lpRect, UINT cKids, const HWND *lpKids);wHow : [in] Specifies a cascade flag. This parameter can be one or more of the following values. MDITILE_SKIPDISABLED: Prevents disabled multiple-document interface (MDI) child windows from being cascaded. MDITILE_ZORDER: Windows 2000/XP: Arranges the windows in Z order. If this value is not specified, the windows are arranged using the order specified in the lpKids array. For other parameters, refer: TileWindows (above)[/list]Remarks :

By default, CascadeWindows arranges the windows in the order provided by the lpKids array, but preserves the Z-Order. If you specify the MDITILE_ZORDER flag, CascadeWindows arranges the windows in Z order.

Calling CascadeWindows causes all maximized windows to be restored to their previous size.

You can also set the area where the windows should be Tiled / Cascaded. You can also pass the list of windows handles, and limit the tiling/cascading to a set of windows. But those parameters have to passed as pointers to an Array and a Structure. With some patience, I was able to understand InsertInteger() provided in the help file ( DllCall ), but I do not have the knowledge to explain it.

Instead, I provide here the WinArrange.ahk written as a wrapper for those two functions. You may just include the wrapper in your script and call the WinArrange() function with much ease. Simply put, you call the WinArrange(), and it takes care of creating the RECT structure and the array of window handles.

Here is an example that demonstrates the use of above wrapper. You can Copy / Paste & Try it but you require to download the wrapper first : Download : WinArrange.ahk

The following script opens two instances of Windows Explorer to allow ease copy/move tasks between folder/drives. You can control those two windows with the WinArrange() function provided in the wrapper. Exiting the script will close the windows.

I have used anly two windows in the above example. With WinGet, Var, List creating a list of window handles is very easy. Combining it with ahk_class will give you many probabilities in arranging windows.

I am able see instances where these functions could prove useful.

One may have many instances of Internet Explorer and with the Cascade Windows facility, you can Cascade only the IE windows!Reading the IE titlebar would allow easy window selection.

You might be alt-tab`ing hard between your script, .ini & other includes.You can tile only those windows opened by notepad/other editor with a hotkey and view all those files in one go!

I guess, I am tired... Let me see if I can post a part 2 with more examples.

SKAN, I'd been using variants of your programs, with a hotkey to tile
all windows or cascade them. I'd like to have a little more control
though, but don't know if it can be done:

1. tile only selected windows
Say there are 5 windows on the desktop. I'd like to tile just 2 of them (select with Control-LMB) ie. the 2 selected windows gets tiled on top of the other windows.

2. Cascade all windows based on a selected windows
size
Say there're 5 windows on the desktop. I resize one of them (thus it becomes the topmost window) and cascade all windows. All windows sizes will be the same size as the selected one, but cascaded behind it.

1. tile only selected windowsSay there are 5 windows on the desktop. I'd like to tile just 2 of them (select with Control-LMB) ie. the 2 selected windows gets tiled on top of the other windows.

I do not get the idea. The exact facility is already available in XP atleast.You may select any number of Windows from taskbar with Ctrl+LButton and right click and select Tile windows from Context menu

2. Cascade all windows based on a selected windows sizeSay there're 5 windows on the desktop. I resize one of them (thus it becomes the topmost window) and cascade all windows. All windows sizes will be the same size as the selected one, but cascaded behind it.

For custom cascading, we will have to use WinMove on every other window on Desktop..

I do not understand. Even edit/text controls are child windows.. Can you please elaborate?

Oh sorry, what I mean is, I have several GUI's with the "+ParentAnotherGUI" option. So they're basically inside the Main GUI. Is it possible to tile or cascade them using your function? I tried it but I can't seem to get it to work.

Got it working now, I used your DllCall solution. I did some research at MSDN a few days back regarding this, and I always assumed that I have to provide the "lpRect" parameter for which I do not know how. The parameter is optional and I need not provide it all the while. Many thanks Skan.