An open API service indexing awesome lists of open source software.

https://github.com/nstechbytes/restore-window

Node.js library to restore or minimize a Windows window by its exact title.
https://github.com/nstechbytes/restore-window

Last synced: 4 months ago
JSON representation

Node.js library to restore or minimize a Windows window by its exact title.

Awesome Lists containing this project

README

          

# restore-window

**CLI + Node.js library** to restore or minimize a Windows window by its exact title, available with both synchronous and asynchronous APIs.

---

## 🔧 Features

- **Restore** a minimized window by title
- **Minimize** a visible window by title
- **Zero-JS-shim CLI**: invokes the native `restore-window.exe` directly
- **Node.js API** for programmatic control (sync & async)
- **Windows-only** (skips install on other platforms)

---

## 📦 Installation

```bash
npm install -g restore-window
```

> ⚠️ Windows only. On non-Windows platforms the installer will warn and exit harmlessly.

---

## 🚀 Usage

### CLI

Invoke the native binary directly:

```bash
restore-window -t "Untitled - Notepad" -restore
restore-window -t "My App" -minimize
```

* `-t ""`
* Exactly **one** of:
* `-restore`
* `-minimize`

If the window is not found or already in the requested state, an error or status message is printed.

---

### API

#### Synchronous (blocking)

```js
const rw = require('restore-window');

// restore a window
try {
const msg = rw.restoreSync("Untitled - Notepad");
console.log(msg); // → Window 'Untitled - Notepad' restored.
} catch (err) {
console.error(err.message);
}

// minimize a window
try {
const msg = rw.minimizeSync("Calculator");
console.log(msg); // → Window 'Calculator' minimized.
} catch (err) {
console.error(err.message);
}
```

#### Asynchronous (non-blocking)

```js
const rw = require('restore-window');

(async () => {
try {
const msg1 = await rw.restore("Untitled - Notepad");
console.log(msg1); // → Window 'Untitled - Notepad' restored.

const msg2 = await rw.minimize("Calculator");
console.log(msg2); // → Window 'Calculator' minimized.
} catch (err) {
console.error(err.message);
}
})();
```

---

## 🤝 Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/my-feature`)
3. Commit your changes (`git commit -m "feat: add ..."`)
4. Push to the branch (`git push origin feature/my-feature`)
5. Open a Pull Request

Please ensure all new code is covered by tests and follows the existing style.

---

## 📄 License

This project is licensed under the **MIT License**. See [LICENSE](LICENSE) for details.