Package Exports
- @miniben90/x-win
- @miniben90/x-win/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@miniben90/x-win) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@miniben90/x-win
This project uses Rust and napi-rs to make it easy to obtain the active window or an array of open windows. It works on Microsoft Windows (10, 11), Linux (with X server), and macOS.
How to install
# With npm
npm i @miniben90/x-win
# With yarn
yarn add @miniben90/x-win
How to use
Get information about the currently active window
exemple.ts
:
import { activeWindow, type WindowInfo } from '@miniben90/x-win';
const currentWindow: WindowInfo = activeWindow();
console.log(currentWindow);
response
:
{
id: 26148,
info: {
execName: "Code",
name: "Visual Studio Code",
path: "C:\\Users\\miniben\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe",
processId: 26148
},
os: "win32",
position: {
height: 1048,
width: 1936,
x: -8,
y: -8
},
title: "● README.md - x-win - Visual Studio Code",
usage: {
memory: 113270784
}
}
Get a list of open windows with information
exemple.ts
:
import { openWindows, type WindowInfo } from '@miniben90/x-win';
const windows: WindowInfo[] = openWindows();
console.log(windows);
response
:
[{
id: 26148,
info: {
execName: "Code",
name: "Visual Studio Code",
path: "C:\\Users\\miniben\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe",
processId: 26148
},
os: "win32",
position: {
height: 1048,
width: 1936,
x: -8,
y: -8
},
title: "● README.md - x-win - Visual Studio Code",
usage: {
memory: 113270784
}
}]
Linux
Dependencies are required to be installed for development purposes.
sudo apt install libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxcb-shm0-dev
Darwin
Screen recording permission introduced in macOS 10.15 Catalina
macOS requires you to grant access for screen recording. If your project does not have it, the title will display
<unknown>
as its value.
Project References
Project Inspirations:
- active-win
- active-win-pos-rs
- This project was generated with @napi-rs/cli