electron-window-exclude-capture
v1.0.6
Published
Native content protection for Electron windows on Windows, with dummy fallback on macOS/Linux.
Readme
electron-content-protection
A lightweight native module to enforce content protection/anti-screenshotting on Electron windows using Windows APIs. On macOS/Linux, it gracefully falls back to a dummy implementation so it does not crash or break compiling.
Installation
npm install electron-content-protectionPublishing to NPM
To publish this package to NPM:
- Log in to NPM:
npm login - Publish:
Note: Only files defined in thenpm publishfilesarray inpackage.jsonwill be uploaded. The localbuild/directory is automatically ignored, allowing npm to build the module from source for each consumer's platform.
Usage in Electron
const { setWindowExcludeFromCapture } = require('electron-content-protection');
// Fallback to native on Windows
if (process.platform === 'win32') {
try {
const hwnd = win.getNativeWindowHandle();
const result = setWindowExcludeFromCapture(hwnd);
console.log('Native content protection applied:', result);
} catch (error) {
console.error('Failed to apply native content protection:', error);
}
}