JosephusPaye / list-open-windows

List the windows of currently open applications on Windows.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

List Open Windows

A native Node.js module for listing the currently open application windows on Windows. Can be paired with activate-previous-window to create a task switcher.

Why

It's easy enough to get a list of open windows using the EnumWindows function. The problem is that EnumWindows returns a lot of other things that are not what you would expect: tooltips, background windows, hidden windows, etc. This module uses a few heuristics to filter the list from EnumWindows to include only what you would see when you press Alt+Tab.

Installation

npm install @josephuspaye/list-open-windows --save

Usage

const { listOpenWindows } = require('@josephuspaye/list-open-windows');

// Get the list of open windows
const windows = listOpenWindows();

// Do something with the list
windows.forEach(console.log);

listOpenWindows() takes no parameter and returns a list of window objects with the following properties:

  • handle (number) the window handle (HWND)
  • zOrder (number) the window position in z-order
  • className (string) the window class name, as retrieved from GetClassName
  • caption (string) the window title/caption, as retrieved from GetWindowText
  • processId (string) the id of the thread that the window belongs to, as retrieved from GetWindowThreadProcessId
  • processPath (string) the path to the executable of the process that the window belongs to, as retrieved from GetModuleFileNameEx

Licence

MIT

About

List the windows of currently open applications on Windows.

License:MIT License


Languages

Language:C++ 89.6%Language:JavaScript 6.6%Language:Python 3.7%