---
title: "getWindowRect"
canonical: "https://help.vicon.com/space/ShogunPost121/1253736538/getWindowRect"
format: markdown
---
# Description

Gets the bounding rectangle of the User Window specified by `windowId`.

The return value represents a rectangle holding the Left, Top, Right, and Bottom values of the user window. User controls placed with [setControlPos](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737132) or the `-pos` option on creation should be placed relative to the top left corner of the user window.

## Functional area

User Window

# Command syntax

## Syntax

> Macro (scroll-tablelayout)

|  |
| --- |
| `getWindowRect userWindowID` |

### Arguments

> Macro (scroll-tablelayout)

| Name | Type | Required | Comments |
| --- | --- | --- | --- |
| `userWindowID` | int | yes | ID of user window to get the bounding rectangle for. |

### Flags

None

## Return value

integer array

> Macro (scroll-pagebreak)

## Examples

```plaintext
// Get the bounding rect of a User Window, and place
// a control within it.
int $windowId;
int $controlId;
int $rect[4], $controlRect[4];
 
// First create a User Window to place the Control on
$windowId = `createWindow "MyWindow"`;
 
// Create a Text Box Control in the window.
$controlId = `createTextBox $windowId -text "Get Window Rect Sample"`;
 
// Get the rect of the User Window.
$rect = `getWindowRect $windowId`;
 
// Position the control in the middle of the User Window
$controlRect[0] = $rect[0];
$controlRect[1] = ($rect[1] + $rect[3]) / 2;
$controlRect[2] = $rect[2];
$controlRect[3] = $controlRect[1] + 24;
setControlPos $controlId $controlRect;
```

# Additional information

## Related commands

- [getControlPos](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738647)
- [setControlPos](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737132)