JSPM

  • Created
  • Published
  • Downloads 28
  • Score
    100M100P100Q86104F
  • License MIT

Get position, size, title and a few other properties of the active or open window(s) on Windows, MacOS and Linux.

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

CI Node version npm type definitions

@miniben90/x-win

This project work with Rust and napi-rs to make easy to have active window or an array of open windows. It work with Microsoft Windows (10, 11), Linux (With Xserver) and Macos(*).

How to install

Easy to install:

# With npm
npm i @miniben90/x-win

# With yarn
yarn add @miniben90/x-win

How to use

Get information of current 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 List of open windows with informations

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
  }
}]

For Darwin

Record screen required for macos

Macos require to grant access for recording screen. If your project don't have it the title will have <unknown> as value.


This project was inspired by: