handler for CTRL_C_EVENT, CTRL_BREAK_EVENT, CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, CTRL_SHUTDOWN_EVENT
Tested against Windows 10 / Python 3.11 / Anaconda
pip install consolectrlchandler
Console Control Handler for Windows
This module provides functionality for handling console control events in Windows,
namely CTRL_C_EVENT, CTRL_BREAK_EVENT, CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, CTRL_SHUTDOWN_EVENT
Args:
ctrl_type (int): The type of control event.
Returns:
bool: True if the event is handled; False otherwise.
Example:
To use this module, import it and set your desired function as the console handler:
>>> from consolectrlhandler import ctrl_config
Define your custom function to handle console control events:
>>> def ctrl_handler(ctrl_type):
... print(f"Received control event: {ctrl_type}")
Assign your custom function as the console handler:
>>> ctrl_config.function = ctrl_handler
Then run your main program loop.
# Complete code
from consolectrlchandler import ctrl_config
import time
def ctrlhandler(ctrl_type):
print(f"ctrl handler {ctrl_type}")
ctrl_config.function = ctrlhandler
while True:
print("test")
time.sleep(1)
test
test
ctrl handler 0
test
ctrl handler 0
ctrl handler 0
ctrl handler 0
ctrl handler 0
test
ctrl handler 0
test
test
Metadata
Release files for consolectrlchandler 0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| consolectrlchandler-0.11.tar.gz | 3.6 kB | Without provenance | Details for consolectrlchandler-0.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| consolectrlchandler-0.11-py3-none-any.whl | Python 3 | none | any | Details for consolectrlchandler-0.11-py3-none-any.whl |
Total release size: 8.5 kB
Release files / consolectrlchandler-0.11.tar.gz
| Download URL | consolectrlchandler-0.11.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92942110a4f70ef64e61aae771bf8fbf4a66a09beb16efd5ba42ca91260eba57
|
|
BLAKE2b-256 checksum How to use checksums |
27e2a4b5fa2ae21e823e09fa527ade0c07f8d55d375e1d272fa9eb3a5a1fa866
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / consolectrlchandler-0.11-py3-none-any.whl
| Download URL | consolectrlchandler-0.11-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e905dd9a5bda146d3847b48ffb47e31e58e69d5f2887e8ea0158d2f715fc115b
|
|
BLAKE2b-256 checksum How to use checksums |
f80c2bdf279f7890dfc66360177fdd68f3a7637970211fb8a9b5a5626018cecd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Security for consolectrlchandler 0.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.