Use activeWindow(options?) to asynchronously retrieve metadata about the currently focused window. It returns a Promise that resolves to a Result object or undefined if no active window is found. The returned Result is platform-specific (macOS, Windows, or Linux).
import {activeWindow} from 'get-windows';
const result = await activeWindow();
if (!result) {
return;
}
if (result.platform === 'macos') {
// Among other fields, `result.owner.bundleId` is available on macOS.
console.log(`Process title is ${result.title} with bundle id ${result.owner.bundleId}.`);
} else if (result.platform === 'windows') {
console.log(`Process title is ${result.title} with path ${result.owner.path}.`);
} else {
console.log(`Process title is ${result.title} with path ${result.owner.path}.`);
}