# winapi

> Misc windows API wrappers

Latest version **2.10.1** (published 2023-10-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install winapi
pnpm add winapi
yarn add winapi
bun add winapi
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.10.1 |
| Published | 2023-10-23 |
| First published | 2016-02-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 462.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 60 |
| Author | Francois Leurent |
| Maintainers | 131, idjem, frodon |
| Keywords | screensaver, GetLastInputInfo, winapi, windows.h, activity, idletimer |

## Links

- npm: https://www.npmjs.com/package/winapi
- Repository: https://github.com/131/node-winapi
- Homepage: https://github.com/131/node-winapi#readme
- Issues: https://github.com/131/node-winapi/issues
- npm.io page: https://npm.io/package/winapi

## Dependencies (2)

- [nan](https://npm.io/package/nan.md) ^2.18.0
- [node-gyp-build](https://npm.io/package/node-gyp-build.md) ^4.4.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.10.1 (latest) — 2023-10-23
- 2.10.0 — 2023-01-11
- 2.9.15 — 2023-01-11
- 2.9.13 — 2023-01-11
- 2.9.12 — 2023-01-10
- 2.9.11 — 2023-01-10
- 2.9.8 — 2022-10-04
- 2.9.6 — 2022-05-20
- 2.9.4 — 2022-05-17
- 2.9.3 — 2022-05-16
- 2.9.2 — 2022-05-16
- 2.9.1 — 2022-04-01
- 2.8.1 — 2021-10-08
- 2.8.0 — 2020-10-22
- 2.7.6 — 2020-04-16
- … 21 more at https://npm.io/package/winapi/versions

## README

# winapi
Misc natives MS Windows API wrappers for nodejs & nwjs

[![Version](https://img.shields.io/npm/v/winapi.svg)](https://www.npmjs.com/package/winapi)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT)
[![Available platform](https://img.shields.io/badge/platform-nwjs-blue.svg)](https://www.npmjs.com/package/winapi) [![Available platform](https://img.shields.io/badge/platform-win32-blue.svg)](https://www.npmjs.com/package/winapi)
[![Code style](https://img.shields.io/badge/code%2fstyle-ivs-green.svg)](https://www.npmjs.com/package/eslint-plugin-ivs)



# API

## require('winapi').getIdleTime()
Return the time the system has been idle (since last user interaction - e.g. mouse, keyboard & stuffs, see GetLastInputInfo)
This is really usefull if you want to create a screensaver/like in nodejs / node-webkit.

```
var winapi = require('winapi');

console.log("System is idle since %s", winapi.getIdleTime() );

```

## require('winapi').CreateJobGroup()
Create a [job group](https://docs.microsoft.com/fr-fr/windows/desktop/ProcThread/job-objects) with current process and all future child_process. Use this to kill zombies. Like Rick.

```
var winapi = require('winapi');

winapi.CreateJobGroup();

//you can now spawn subprocess and they'll be killed once you died, windows will clean everything up

```
* (checkout my [dispatcher](https://github.com/131/dispatcher) project for inspiration)
* Available for node 8, nw 26 and nw 14. (i did not re-compile other platform binaries, do it by yourself...)




## require('winapi').GetLastInputInfo()
Use this native binding to get system last input time ([see MSDN](https://msdn.microsoft.com/en-us/library/windows/desktop/ms646302%28v=vs.85%29.aspx) )

```
var winapi = require('winapi');

console.log("Last input time is %s", winapi.GetLastInputInfo() );

setTimeout(function(){
  //do not move, it wont change !
  console.log("Last input time is %s", winapi.GetLastInputInfo() );
}, 1000);

```


## require('winapi').GetChildrenProcess([parentProcessId])
List all children process (of specified parent PID, default to current process)


## require('winapi').GetParentProcess([childProcessId])
Get a process parent PID (of specified process PID, default to current process)



## require('winapi').GetTickCount()
Retrieves the number of milliseconds that have elapsed since the system was started (uptime). ([see MSDN](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724408%28v=vs.85%29.aspx) )

### require('winapi').GetDisplaysList(console.log)
List all connected screens

# Credits
* [131](mailto:131.js@cloudyks.org)
* Code signing, courtesy of IVS Group.


# Keywords / shout box
screensaver, windows api, winuser.h, GetLastInputInfo, activity monitor, inactivity trigger, idle timer, system uptime, sytem bootime

---
_Source: https://npm.io/package/winapi · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
