This package provides a Node.js API wrapper for the Windows API function `AllowSetForegroundWindow`. It enables a process to allow other specified processes, or all processes, to set its foreground window, which is critical for managing window focus behavior in desktop applications, automation scripts, or Electron projects on Windows. The current stable version is 0.6.1, with releases typically occurring as needed for bug fixes, performance enhancements, or build system updates, rather than a fixed schedule. A key differentiator is its direct implementation via Node-API, providing low-level, reliable control over Windows foreground window permissions. It's explicitly designed for the Windows environment, providing no functionality on other operating systems. The package includes comprehensive TypeScript typings, enhancing developer experience and compile-time safety for TypeScript projects.
npm install windows-foreground-loveVerified import paths — ran on the pinned version, not inferred.
This code snippet demonstrates how to use `windows-foreground-love` to grant foreground activation permission, both for a specific process (the current one) and globally for all processes, highlighting its Windows-specific behavior.
Ensure the application using this package runs exclusively on Windows when foreground window control is required. Implement platform checks if cross-platform support is necessary for other features.
Install `node-gyp` globally (`npm install -g node-gyp`) and ensure you have the necessary build tools for your Node.js version, typically by running `npm install --global windows-build-tools` (for older Node versions) or installing Visual Studio Build Tools with the 'Desktop development with C++' workload for newer versions.
Always specify a `pid` if you only intend to grant foreground rights to a particular process. Only use the parameter-less call if you fully understand and accept the global impact.
Install Visual Studio Build Tools (for newer Node.js versions) or `windows-build-tools` (for older Node.js versions) to provide the necessary C++ compiler and headers. Ensure `node-gyp` is globally installed and configured correctly.
Ensure you are accessing the `allowSetForegroundWindow` function correctly. Use `const { allowSetForegroundWindow } = require('windows-foreground-love');` or `const allowSetForegroundWindow = require('windows-foreground-love').allowSetForegroundWindow;`.No dependency data recorded yet.