# jsgetwindow

> a cross platform module to obtain GUI information and controlling application's windows (inspired from PyGetWindow)

Latest version **1.0.2** (published 2023-12-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install jsgetwindow
pnpm add jsgetwindow
yarn add jsgetwindow
bun add jsgetwindow
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-12-18 |
| First published | 2023-12-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Deepanshu Sharma |
| Maintainers | woustached |
| Keywords | Cross-platform module, GUI information, Window control, pyGetWindow module, Development in progress, Windows platform, Application windows |

## Links

- npm: https://www.npmjs.com/package/jsgetwindow
- Repository: https://github.com/woustachemaxd/JsGetWindow
- Homepage: https://github.com/woustachemaxd/JsGetWindow#readme
- Issues: https://github.com/woustachemaxd/JsGetWindow/issues
- npm.io page: https://npm.io/package/jsgetwindow

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2023-12-18
- 1.0.1 — 2023-12-18
- 1.0.0 — 2023-12-18

## README

# JsGetWindow

A cross-platform module designed for retrieving GUI information and managing application windows. Inspired from the pyGetWindow module.

Still under development. Currently only the Windows platform is implemented.



## Installation

Install jsGetWindow with npm

```bash
  npm i jsgetwindow
```
    
## API Reference

#### Functions

| Function Name | Output | Description |
| :------------- | :---- | :---------- |
| `getAllTitles()` | `String[]` | Retrieves titles of all visible windows. |
| `getAllWindows()` | `BaseWindow[]` | Retrieves details of all visible windows. |
| `getActiveWindow()` | `BaseWindow` | Retrieves details of the currently active window. |
| `getActiveWindowTitle()` | `String` | Retrieves the title of the currently active window. |
| `getCursorPosition()` | `{ x: number, y: number }` | Retrieves the position of the cursor. |
| `getWindowsAt(x:number, y:number)` | `BaseWindow[]` | Retrieves details of windows at the given coordinates. |
| `getWindowsWithTitle(title:String)` | `BaseWindow[]` | Retrieves details of windows with the specified title. |


#### Window Methods: 

```javascript
const window = getActiveWindow(); //BaseWindow object
window.close();
```

| Method | Description |
| :-------- | :---------- |
| `close()` | Closes the window. |
| `minimize()` | Minimizes the window. |
| `maximize()` | Maximizes the window. |
| `restore()` | Restores the window. |
| `show()` | Shows the window. |
| `hide()` | Hides the window. |
| `focus()` | Focuses on the window. |
| `resizeTo(width:number, height:number)` | Resizes the window to the given width and height. |
| `resizeOffset(widthOffset:number, heightOffset:number)` | Resizes the window by the given width and height offsets. |
| `moveTo(x:number, y:number)` | Moves the window to the given x, y coordinates. |
| `moveOffset(xOffset:number, yOffset:number)` | Moves the window by the given x, y offsets. |

#### Window Properties

```javascript
const window = getActiveWindow(); //BaseWindow object
console.log(window.isActive); // true
```

| Property | Output | Description |
| :-------- | :----- | :---------- |
| `resolution` | `{ width: number, height: number }` | Gets the resolution of the window (width, height). |
| `x` | `number` | Gets the x coordinate of the window. |
| `y` | `number` | Gets the y coordinate of the window. |
| `isMaximized` | `boolean` | Checks if the window is maximized. |
| `isMinimized` | `boolean` | Checks if the window is minimized. |
| `isActive` | `boolean` | Checks if the window is active. |
| `isVisible` | `boolean` | Checks if the window is visible. |


BaseWindow object
```javascript
{

    title: String,
    rect: Rect {
        left: number,
        top: number,
        right: number,
        bottom: number
    },
    handle: number

}
```
## Function Example

```javascript
> const gw = require("jsGetWindow");
undefined

> gw.getAllTitles();
[ 'new.js - test - Visual Studio Code',  'readme.so - Google Chrome', 'main.js - libProj - Visual Studio Code', 'Hannibal (2013) - S01E12 - Relevés (1080p BluRay x265 RCVR).mkv - PotPlayer', 'Realtek Audio Console', 'Command Prompt - py  reader1.py',  'Settings',  'Settings', 'Windows Input Experience' 'Program Manager' ]

> gw.getActiveWindow()
BaseWindow {
  title: 'new.js - test - Visual Studio Code',
  rect: Rect { left: -7, top: -7, right: 1714, bottom: 920 },
  handle: 328462
}

> gw.getWindowsWithTitle("chrome")
[
BaseWindow {
    title: 'woustachemaxd/JsGetWindow - Google Chrome',
    rect: Rect { left: -7, top: -7, right: 1714, bottom: 920 },
    handle: 198404
  },
    BaseWindow {
    title: 'Toby - Google Chrome',
    rect: Rect { left: -7, top: -7, right: 1714, bottom: 920 },
    handle: 2361776
  }
]

> gw.getActiveWindow().title
'new.js - test - Visual Studio Code'

> gw.getAllWindows();
[
  BaseWindow {
    title: 'new.js - test - Visual Studio Code',
    rect: Rect { left: -7, top: -7, right: 1714, bottom: 920 },
    handle: 328462
  },
  BaseWindow {
    title: 'readme.so - Google Chrome',
    rect: Rect { left: -7, top: -7, right: 1714, bottom: 920 },
    handle: 198404
  },
    ...
  BaseWindow {
    title: 'Program Manager',
    rect: Rect { left: 0, top: 0, right: 1707, bottom: 960 },
    handle: 65942
  }
]

>
```


## Method and Properties Example

```javascript
> chromeWindow = gw.getWindowsWithTitle("chrome")[0]
> chromeWindow.isMaximized
False
> chromeWindow.maximize()
> chromeWindow.isMaximized
True
> chromeWindow.minimize()
> chromeWindow.restore()
> chromeWindow.activate()
> chromeWindow.resizeOffset(10, 10) # increase by 10, 10
> chromeWindow.resizeTo(100, 100) # set size to 100x100
> chromeWindow.moveOffset(10, 10) # move 10 pixels right and 10 down
> chromeWindow.moveTo(10, 10) # move window to 10, 10
> chromeWindow.close()
```

---
_Source: https://npm.io/package/jsgetwindow · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
