You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

desktop-detector

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

desktop-detector

Detect when Windows desktop is in foreground

1.4.0
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

🖥️ desktop-detector

A small Windows utility and Node.js wrapper that detects when the desktop becomes the foreground window (i.e., when all applications are minimized).

This version improves detection by distinguishing between a true "Show Desktop" (triggered via Win+D or the taskbar button) and a simple click on the desktop:

  • Show Desktop is recognized when:
    • Any window minimize-start event occurs within a 500-millisecond window before desktop activation (meaning a "burst" of one or more minimization events).
    • It is triggered via the "Show Desktop" button or the Win+D hotkey.
  • A plain click on the desktop is ignored as a "Show Desktop" event and logs only a simple "shown" state.

⚙️ Features

  • Detects when the Windows desktop is shown or hidden (based on focus).
  • Distinguishes "Show Desktop" (via key/button) from ordinary clicks.
  • Exposes a clean JavaScript API for use in Node.js.
  • Optional --quiet and --log CLI flags for flexible output.

📦 Installation

npm install desktop-detector

Or clone it:

git clone https://github.com/nstechbytes/desktop-detector.git
cd desktop-detector
npm install

🚀 Usage

In Node.js:

const { startDesktopDetector } = require('desktop-detector');

// Start monitoring
const proc = startDesktopDetector({
  quiet: false, // show console output
  log: true     // also log to `detect-desktop.log`
});

// Optional: stop after 10 seconds
setTimeout(() => {
  proc.kill();
  console.log("Stopped detector.");
}, 10000);

🧰 CLI Options

You can also run the binary directly:

./bin/detect-desktop.exe [--quiet] [--log] [--help]
FlagDescription
--quietSuppresses console output
--logLogs output to detect-desktop.log
--helpDisplays usage information

🧪 Example Output

[2025-05-24 16:00:00] Initial state: Desktop is BACKGROUND
[2025-05-24 16:00:00] Listening for Show Desktop; press Ctrl+C to exit.
[2025-05-24 16:01:10] *** Desktop is now FOREGROUND (Show Desktop)
[2025-05-24 16:01:12] *** Desktop is now BACKGROUND (apps restored via desktopMode)
[2025-05-24 16:02:00] *** Desktop is now FOREGROUND (shown)

📜 License

MIT © nstechbytes

Keywords

desktop

FAQs

Package last updated on 27 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.