https://github.com/zenflow/generate-ctrl-c-event
Generate ctrl-c (or ctrl-break) events on Windows by calling `Kernel32::GenerateConsoleCtrlEvent()`
https://github.com/zenflow/generate-ctrl-c-event
ctrl-c ctrl-cevent windows
Last synced: 11 months ago
JSON representation
Generate ctrl-c (or ctrl-break) events on Windows by calling `Kernel32::GenerateConsoleCtrlEvent()`
- Host: GitHub
- URL: https://github.com/zenflow/generate-ctrl-c-event
- Owner: zenflow
- License: mit
- Created: 2020-09-15T04:03:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-16T16:23:07.000Z (over 4 years ago)
- Last Synced: 2025-02-28T14:44:11.722Z (12 months ago)
- Topics: ctrl-c, ctrl-cevent, windows
- Language: JavaScript
- Homepage:
- Size: 308 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# generate-ctrl-c-event
Generate ctrl-c (or ctrl-break) events on Windows by calling [`Kernel32::GenerateConsoleCtrlEvent()`](https://docs.microsoft.com/en-us/windows/console/generateconsolectrlevent)
[](http://npmjs.com/package/generate-ctrl-c-event)
[](https://david-dm.org/zenflow/generate-ctrl-c-event)
[](https://david-dm.org/zenflow/generate-ctrl-c-event?type=optional)
[](https://codeclimate.com/github/zenflow/generate-ctrl-c-event)
[](https://lgtm.com/projects/g/zenflow/generate-ctrl-c-event/)
[](https://snyk.io/test/github/zenflow/generate-ctrl-c-event?targetFile=package.json)
[](https://github.com/zenflow/generate-ctrl-c-event/issues)
[](https://github.com/zenflow/generate-ctrl-c-event/pulls)
[](https://opensource.org/licenses/MIT)
Only works on Windows.
Cannot be installed on other platforms due to it's [`package.os`](https://docs.npmjs.com/files/package.json#os).
If you need to use this in cross-platform code,
install it as an [optional dependency](https://docs.npmjs.com/files/package.json#optionaldependencies)
and it will be skipped when installing your package on a non-Windows platforms.
Calls [`Kernel32::GenerateConsoleCtrlEvent()`](https://docs.microsoft.com/en-us/windows/console/generateconsolectrlevent),
via either a Foreign Function Interface (FFI) if available, or a PowerShell script as a fallback.
Please consult the official docs on [`Kernel32::GenerateConsoleCtrlEvent()`](https://docs.microsoft.com/en-us/windows/console/generateconsolectrlevent) for semantics.
Exports:
```typescript
function generateCtrlC(): boolean
function generateCtrlCAsync(): Promise
function generateCtrlBreak(dwProcessGroupId: number = 0): boolean
function generateCtrlBreakAsync(dwProcessGroupId: number = 0): Promise
```