The Windows struct provides methods to access the Windows OS' User Interface elements.
Unless noted otherwise, these methods are available in 3ds Max 2008 and higher.
They were previously available in the Avguard Extensions .
This method returns the HWND of the main 3ds Max window as an integer (Pointer value).
This method returns the HWND of the MS Window's desktop as an integer (Pointer value).
windows.sendMessage <int HWND> <int message> <int messageParameter1> <int messageParameter2>
Sends a Win32 message to the HWND specified in the first argument.
The second argument is the message ID, usually specified as hexadecimal number.
The third and fourth arguments are the message parameters. When no parameters are expected, pass 0 as a placeholder.
windows.postMessage <int HWND> <int message> <int messageParameter1> <int messageParameter2>
Calls the Window's PostMessage function passing the argument values.
Available in 3ds Max 2011 and higher.
windows.processPostedMessages()
Runs a message pump that retrieves any pending Window's messages and dispatches them to 3ds Max.
Calling this method will process all pending messages. It can be used inside a MAXScript loop which would otherwise cause a "white screen" in Windows 7 due to 3ds Max being unresponsive while performing long calculations.
Available in 3ds Max 2011 and higher.
This method returns an array of the children windows of the specified HWND, recursively.
If the specified HWND is 0, only the top level desktop windows are returned (not recursively).
If the parent HWND is specified, only windows whose immediate parent is the specified window are returned.
If #max is specified as the HWND, the HWND associated with the 3ds Max main window is used.
If the specified HWND does not exist, the value undefined is returned.
Otherwise, an array is returned.
Each element of the array corresponds to a window, and contains an 8 elements array (originally, only the first 5 elements were returned in 3ds Max 2008)
The elements of these arrays represent the window's:
2: the parent HWND. This does not include the owner (GetAncestor(hWnd,GA_PARENT))
3: the parent or owner HWND. If the window is a child window, the return value is a handle to the parent window. If the window is a top-level window, the return value is a handle to the owner window. (GetParent(hWnd))
4: class name as a string (GetClassName(hWnd, className, bufSize)) - limit of 255 characters
5: window text as a string (GetWindowText(hWnd, windowText, bufSize)) - limit of 255 characters
6: the owner's HWND (GetWindow(hWnd,GW_OWNER))
7: root window HWND. The root window as determined by walking the chain of parent windows (GetAncestor(hWnd,GA_ROOT))
8: owned root window HWND. The owned root window as determined by walking the chain of parent and owner windows returned by GetParent (GetAncestor(hWnd,GA_ROOTOWNER))
The mehod returns the child window of the specified HWND with the given child window's text. Child windows are recursively searched.
If the specified HWND is 0, only the top level desktop windows are searched (not recursively).
If the parent HWND is specified, only windows whose immediate parent is the specified window are searched.
If #max is specified as the HWND, the HWND associated with 3ds Max main window is used.
If the specified HWND does not exist, the value undefined is returned.
If a child window with the specified text is not found, undefined is returned.
The text comparison is case insensitive.
If a match is found, an 8 element array is returned. See the documentation of the windows.getChildrenHWND() method above for details on their meaning.
windows.getHWNDData {<int HWND>|#max}
Returns data associated with the specified HWND.
If #max is specified as the HWND, the HWND associated with the 3ds Max main window is used.
If the specified HWND does not exist, the value undefined is returned.
If a match is found, a 8 element array is returned. See the documentation of the windows.getChildrenHWND() method above for details on their meaning.
Available in 3ds Max 2011 and higher.
Note that in 3ds Max 2011 and higher, rollouts and rollout controls expose a read-only .hwnd property.
In the case of a rollout, the property contains the Window's HWND associated with the rollout, or 0 if the rollout is not open.
In the case of a rollout User Interface control, the property contains an array of the Window's HWND of the rollout containing the rollout, or an empty array of the rollout is not open.
windows.setWindowPos <int HWND> <int x> <int y> <int width> <int height> <bool repaint>
Set the position of the window specified by the HWND to the X and Y coordinates specified by the second and third arguments.
Also set the Width and Height of the window to the values passed as fourth and fifth arguments.
When the sixth argument is set to True, the window will also be repainted.
Available in 3ds Max 2014 and higher.
windows.setWindowPos <int HWND> <Box2 rect> <bool repaint>
Set the position of the window specified by the HWND to the coordinates and size given by the second Box2 argument.
When the third argument is set to True, the window will also be repainted.
Available in 3ds Max 2014 and higher.
<Box2 rect>windows.getWindowPos <int HWND>
Returns the position of the upper left corner and the width and height of the window specified by the HWND argument.
The position is expressed in screen coordinates relative to the upper-left corner of the screen.
Available in 3ds Max 2014 and higher.
<Point2>windows.clientToScreen <int HWND> <int x> <int y>
<Point2>windows.clientToScreen <int HWND> <Point2 clientCoord>
Converts the coordinates from the Client space of the window specified by the first argument to coordinates relative to the upper left corner of the Screen.
Available in 3ds Max 2014 and higher.
<Point2>windows.screenToClient <int HWND> <int x> <int y>
<Point2>windows.screenToClient <int HWND> <Point2 screenCoord>
Converts the coordinates from Screen space relative to the upper left corner into Client space of the window specified by the first argument.
Available in 3ds Max 2014 and higher.
windows.snapshot {<int_HWND>|#max} captureAlpha:<bool> gammaCorrect:<bool> captureScreenPixels:<bool>
NEW in 3ds Max 2015: Creates a Bitmap snapshot of the specified HWND.
If the specified HWND is 0, a snapshot of the Windows Desktop will be taken.
If the argument is set to #max , the HWND associated with the 3ds Max main window will be used.
If the captureAlpha: optional keyword argument is specified and set to True, the viewport Alpha will also be captured. If not specified or set to False, the returned image will contain no Alpha and only the RGB channels.
If the gammaCorrect: optional keyword argument is not specified or set to True, gamma correction will be performed on the returned Bitmap value. If set to False, no gamma correction will be performed.
If the captureScreenPixels: optional keyword argument is set to True, the window desktop pixels will be captured within the region of the specified window.
See also Viewport.GetViewportDib() and gw.getViewportDib().
windows.addChild <int_HWND> <int_HWND>
Makes an ActiveX control whose HWND is passed as first argument the child of the window with HWND passed as second argument.
The first argument cannot be a MAXScript control or rollout, it must be an ActiveX control.
Given that ActiveX controls are considered obsolete since 3ds Max 9, this method can also be considered obsolete.