# window

Below are common examples of `window` functionalities:

```javascript
await eagle.window.show();            // Show plugin window
await eagle.window.hide();            // Hide plugin window

await eagle.window.minimize();        // Minimize window
await eagle.window.restore();         // Restore minimized

await eagle.window.maximize();        // Maximize window
await eagle.window.unmaximize();      // Restore maximized

await eagle.window.setFullScreen(true);       // Set to fullscreen
await eagle.window.setFullScreen(false);      // Exit fullscreen
```

***

#### Methods <a href="#z1a5y" id="z1a5y"></a>

## show() <a href="#kaydt" id="kaydt"></a>

Show and focus the window.

* Returns `Promise<>`

```javascript
await eagle.window.show();
```

***

## showInactive() <a href="#reqm4" id="reqm4"></a>

Show the window but don't focus on it.

* Returns `Promise<>`

```javascript
await eagle.window.showInactive();
```

***

## hide() <a href="#mklts" id="mklts"></a>

Hide the plugin window.

* Returns `Promise<>`

```javascript
await eagle.window.hide();
```

***

## focus() <a href="#lskqe" id="lskqe"></a>

Give the plugin window focus.

* Returns `Promise<>`

```javascript
await eagle.window.focus();
```

***

## minimize() <a href="#de7df" id="de7df"></a>

Minimize the plugin window.

* Returns `Promise<>`

```javascript
await eagle.window.minimize();
```

***

## isMinimized() <a href="#v47e2" id="v47e2"></a>

Determine if the window is minimized.

* Returns `Promise<minimized: boolean>`
  * `minimized` boolean - Whether the window is minimized

```javascript
let isMinimized = await eagle.window.isMinimized();
```

***

## restore() <a href="#yvcxf" id="yvcxf"></a>

Restore the plugin window from a minimized state to its previous state.

* Returns `Promise<>`

```javascript
await eagle.window.restore();
```

***

## maximize() <a href="#a53af" id="a53af"></a>

Maximize the plugin window. If the window has not yet been displayed, this method will also show it (but not focus on it).

* Returns `Promise<>`

```javascript
await eagle.window.maximize();
```

***

## unmaximize() <a href="#tg6me" id="tg6me"></a>

Unmaximize the plugin window.

* Returns `Promise<>`

```javascript
await eagle.window.unmaximize();
```

***

## isMaximized() <a href="#zxdhs" id="zxdhs"></a>

Determine if the window is maximized.

* Returns `Promise<maximized: boolean>`
  * `maximized` boolean - Whether the window is maximized

```javascript
let isMaximized = await eagle.window.isMaximized();
```

***

## setFullScreen(flag) <a href="#leibk" id="leibk"></a>

Set whether the window should be in fullscreen mode.

* `flag` boolean - Whether to set as fullscreen
* Returns `Promise<>`

```javascript
await eagle.window.setFullScreen(true);        // Enter fullscreen
await eagle.window.setFullScreen(false);       // Exit fullscreen
```

***

## isFullScreen() <a href="#irx5v" id="irx5v"></a>

Determine if the window is in fullscreen mode.

* Returns `Promise<fullscreen: boolean>`
  * `fullscreen` boolean - Whether the window is in fullscreen

```javascript
let isMaximized = await eagle.window.isMaximized();
```

***

## setAspectRatio(aspectRatio) <a href="#plpcl" id="plpcl"></a>

This will make the window maintain its aspect ratio.

* `aspectRatio` Float - The aspect ratio to maintain (width / height)
* Returns `Promise<>`

```javascript
await eagle.window.setAspectRatio(16/9);        // Restrict the window aspect ratio to 16:9
```

***

## setBackgroundColor(backgroundColor) <a href="#no73b" id="no73b"></a>

Set the background color of the window.

* `backgroundColor` String - This parameter represents the HEX code of your desired background color.
* Returns `Promise<>`

```javascript
await eagle.window.setBackgroundColor("#FFFFFF");
```

{% hint style="info" %}
Note 1: This property can be set directly in manifest.json.

Note 2: This setting is mainly used to set the default background color of the window when the HTML/CSS content is not yet complete. Proper setting can avoid the flickering of the window display.
{% endhint %}

***

## setSize(width, height) <a href="#mq0dz" id="mq0dz"></a>

Set window size.

* `width` Integer - window width
* `height` - Integer - window height
* Returns `Promise<>`

```javascript
await eagle.window.setSize(720, 480);
```

{% hint style="info" %}
Note: This property can be set directly in manifest.json.
{% endhint %}

## getSize() <a href="#mq0dz" id="mq0dz"></a>

Get window size.

* Returns `Promise<Integer[]>`

```javascript
await eagle.window.getSize();
```

## setBounds(**bounds**)

Adjust the window size and move it to the provided bounds. Any properties not provided will default to their current values.

```javascript
await eagle.window.setBounds({ x: 440, y: 225, width: 800, height: 600 })
```

## getBounds()

Get window bounds.

* Returns `Promise<Rectangle[]>` - object representing the window bounds

```javascript
await eagle.window.getBounds()
```

## setResizable(resizable) <a href="#e56j2" id="e56j2"></a>

Set whether the window supports resizing.

* `resizable` boolean - whether resizing is supported
* Returns `Promise<>`

```javascript
await eagle.window.setResizable(true);
await eagle.window.setResizable(false);
```

{% hint style="info" %}
Note: This property can be set directly in manifest.json.
{% endhint %}

***

## isResizable() <a href="#pyh5l" id="pyh5l"></a>

Whether the window supports resizing.

* Returns `Promise<resizable: boolean>`
  * `resizable` boolean

```javascript
let isResizable = await eagle.window.isResizable();
```

***

## setAlwaysOnTop(flag) <a href="#p5shn" id="p5shn"></a>

Set whether the window should always be displayed in front of other windows.

* `flag` boolean
* Returns `Promise<>`

```javascript
await eagle.window.setAlwaysOnTop(true);
await eagle.window.setAlwaysOnTop(false);
```

***

## isAlwaysOnTop() <a href="#quly3" id="quly3"></a>

Whether the window should always be displayed in front of other windows.

* Returns `Promise<alwaysOnTop: boolean>`
  * `alwaysOnTop` boolean

```javascript
let isAlwaysOnTop = await eagle.window.isAlwaysOnTop();
```

***

## setPosition(x, y) <a href="#erkhe" id="erkhe"></a>

Move the window to x and y.

* `x` Integer
* `y` Integer
* Returns `Promise<>`

```javascript
await eagle.window.setPosition(100, 200);
```

***

## getPosition() <a href="#ua19x" id="ua19x"></a>

Get plugin window coordinates x and y.

* Returns `Promise<position: Integer[]>`
  * `position` Integer\[]
    * x - position\[0]
    * y - position\[1]

```javascript
let position = await eagle.window.getPosition();  // [100, 200]
```

***

## setOpacity(opacity) <a href="#dlzuz" id="dlzuz"></a>

Set the opacity of the window, values outside the range are limited to the \[0, 1] range.

* `opacity` number - between 0.0 (completely transparent) and 1.0 (completely opaque)
* Returns `Promise<>`

```javascript
await eagle.window.setOpacity(0.5);
```

***

## getOpacity() <a href="#fes0x" id="fes0x"></a>

Get window opacity, between 0.0 (completely transparent) and 1.0 (completely opaque).

* Returns `Promise<opacity: number>`
  * `opacity` number

```javascript
let opacity = await eagle.window.getOpacity();
```

***

## flashFrame(flag) <a href="#vxzv7" id="vxzv7"></a>

Start or stop flashing the window to attract the user's attention.

* `flag` boolean - whether to flash
* Returns `Promise<>`

```javascript
await eagle.window.flashFrame(true);
await eagle.window.flashFrame(false);
```

***

## setIgnoreMouseEvents(ignore) <a href="#yvfx8" id="yvfx8"></a>

Ignore all mouse events within the window. All mouse events occurring in this window will be passed to the window below it but if this window has focus, it will still receive keyboard events.

* `ignore` boolean - whether to ignore mouse events
* Returns `Promise<>`

```javascript
await eagle.window.setIgnoreMouseEvents(true);
await eagle.window.setIgnoreMouseEvents(false);
```

{% hint style="info" %}
Combined with the setAlwaysOnTop() feature, you can create a special window that floats at the top of the screen and is permeable to mouse clicks.
{% endhint %}

## capturePage(rect) <a href="#yvfx9" id="yvfx9"></a>

Capture a snapshot of the page within the specified `rect` area. Omitting `rect` will capture the entire visible page.

* `rect` object - Optional, screenshot range
  * `x` number
  * `y` number
  * `width` number
  * `height` number
* Returns `Promise<[NativeImage](https://www.electronjs.org/docs/latest/api/native-image)>`

```javascript
const image = await eagle.window.capturePage();
const base64 = image.toDataURL("image/jpeg");

const image2 = await eagle.window.capturePage({ x: 0, y: 0, width: 100, height: 50 });
const buffer = image2.toPNG();
```

## setReferer(url) <a href="#id-4a6f" id="id-4a6f"></a>

Sets the current referer URL. Once set, subsequent requests will utilize this referer.

* `url` string - The URL of the referer.
* Returns `void`

```javascript
eagle.window.setReferer("https://en.eagle.cool");
```


---

# 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://developer.eagle.cool/plugin-api/api/window.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.
