# Screen

### Get Screen Size

{% code lineNumbers="true" %}

```javascript
const { getScreenSize } = require('positron.js/screen');

const { width, height } = getScreenSize();

if (width && height) {
  console.log(`Your screen resolution is: ${width}x${height}`);
} else {
  console.log("Could not detect screen resolution.");
}
```

{% endcode %}

Retrieves the current horizontal and vertical resolution of the primary display.

* **Returns:** `Object`
  * `width` `(number)`: The horizontal resolution in pixels. Returns `0` if undetected or upon failure.
  * `height` `(number)`: The vertical resolution in pixels. Returns `0` if undetected or upon failure.

### Platform Behavior

The function adapts its underlying command based on `process.platform`:

| Operating System | Command Used                            | Method                                                               |
| ---------------- | --------------------------------------- | -------------------------------------------------------------------- |
| `win32`          | `Get-CimInstance Win32_VideoController` | Queries WMI via PowerShell for active video controller dimensions.   |
| `darwin`         | `system_profiler SPDisplaysDataType`    | Queries Apple System Profiler and parses display resolution strings. |

> Note: On multi-monitor setups, this utility generally returns the resolution of the primary display device.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://positronjs.gitbook.io/v1/modules/screen.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
