This tracker can be used to listen to active window changes on any platform (MacOS, Windows, and Linux)
Add this git repository to your project as a git submodule
git submodule add https://github.com/HASEL-UZH/PA.WindowsActivityTracker
Install the package by adding to package.json and running npm install
npm i ./PA.WindowsActivityTracker/typescript
The simplest example looks as follows
import { WindowsActivityTracker } from "windows-activity-tracker";
const tracker = new WindowsActivityTracker(function (activeWin) {
console.log(activeWin);
});
tracker.start();The url field on the ActiveWindow class is currently only supported on MacOS.
Huge thanks to the maintainers of active-win: https://github.com/sindresorhus/active-win