A cross-platform hot key module.
Project description
PyHotKey
Description
PyHotKey is a cross-platform hot key module for Python. Based on pynput library.
Installation
Using pip:
pip install PyHotKey
Using easy_install:
easy_install PyHotKey
From source file:
a) Download a zip file or a tar.gz file from GitHub or PyPI;
b) Extract the file to a directory;
c) Navigate a terminal session to the directory that contains setup.py;
d) Execute the command below.
python setup.py install
Tip: if you are using Linux, you may need to prepend the command with sudo.
Usage
Importation:
from PyHotKey import manager, Key
Register:
a) prototype:
def RegisterHotKey(self, trigger, keys, count=2, interval=0.5, *args, **kwargs):
"""
:param trigger: the function invoked when the hot key is triggered.
:param list keys: the key list.
:param int count: the number of repeated keystrokes.
:param float interval: the interval time between each keystroke, unit: second.
:param args: the arguments of trigger.
:param kwargs: the keyword arguments of trigger.
:return: returns a key id if successful; otherwise returns -1.
"""
pass
b) Example:
# combination type hot key
key_id1 = manager.RegisterHotKey(func1, [Key.ctrl_l, Key.alt_l, 'z'])
# single keystroke type hot key
key_id2 = manager.RegisterHotKey(func2, [Key.caps_lock], 2, 0.5,
func2_arg1, func2_arg2=1)
Unregister:
result = manager.UnregisterHotKey(key_id1)
View hotkey list:
print(manager.hotKeyList)
Logger:
# Turn on the logger
manager.logger = True
# custom the log path
manager.setLogPath('MyLog.log')
# Turn off the logger
manager.logger = False
Release Note
v1.3.2
Bug Fixes:
- Log path: fix the default log path overwrites the custom log path when setting "manager.logger = True".
Refactor
- Adjust code structure.
- Rewrite README.md.
v1.3.1
- Delete a deprecated class.
- Replace root logger with a separate logger.
- Rename property "hot_keys" to "hotKeyList".
- Change documents and some code comments.
v1.3.0
- Currently, users can customize the log path.
- Optimize code.
v1.2.0
- Add logger.
- Optimize code.
- Attempt to fix a potential bug.
v1.1.1
- Remove log message.
v1.1.0
- Currently, the trigger function supports arguments.
- No longer need to call manager.start() manually.
- Fix multiple type hot key bug.
v1.0
- The first version.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
PyHotKey-1.3.2.tar.gz
(8.5 kB
view details)
Built Distribution
File details
Details for the file PyHotKey-1.3.2.tar.gz
.
File metadata
- Download URL: PyHotKey-1.3.2.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1ba581595b5703bc411a61752024156d5e5b59c2dde03a970b2acd143c14999 |
|
MD5 | 63573afb5deaa15289e53633c8d33c7d |
|
BLAKE2b-256 | cb94978a18ef91b17a2af7410c865d24c6262f20227c4ace4892632a9f9ef010 |
Provenance
File details
Details for the file PyHotKey-1.3.2-py2.py3-none-any.whl
.
File metadata
- Download URL: PyHotKey-1.3.2-py2.py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2338b3400780b3e89c829ed20f3bad78c2e0a60af92a2e074bc4405ad60188a2 |
|
MD5 | 2ef95a7aad503bd0617aa876a2f6b913 |
|
BLAKE2b-256 | b9397bcd26a1378581dff7bc58c7f90f5219097bf4c5b8be1a906248dc4c51e0 |