getSize
Category: Window Management
Namespace: web.window.getSize
Description
Gets the current window size and position.
Syntax
const size = await web.window.getSize();
Parameters
None
Returns
Promise<Object> - Returns a promise that resolves with an object containing:
{
top: number, // Y position from screen top
left: number, // X position from screen left
width: number, // Window width in pixels
height: number // Window height in pixels
}
Examples
Simple example
const size = await web.window.getSize();
console.log('Position:', size.left, size.top);
console.log('Size:', size.width, 'x', size.height);
Save window position
// Save window size and position to variables
const size = await web.window.getSize();
await web.variables.setVar('windowTop', String(size.top));
await web.variables.setVar('windowLeft', String(size.left));
await web.variables.setVar('windowWidth', String(size.width));
await web.variables.setVar('windowHeight', String(size.height));
console.log('Window position saved');
Use Cases
- Get current window dimensions
- Save window position for next session
- Check if window fits on screen
- Calculate relative positions
- Monitor window size changes
Notes
- Returns object with
top,left,width,heightproperties - All values are in pixels
- Position is relative to screen top-left corner
- Returns
nullon error