# Macropy
Keyboard listener, hotkey manager, word expander, task automation, and more!
![Terminal Output](https://github.com/Ryen-042/Macropy/blob/main/Images/Output.png?raw=true)
## Big Update - Cython
Cython is used to compile python source code and make it faster. Cython creates `.c` files that can be compiled into python binary extension modules.
The `macropy/cython_extensions` directory contains all the Cython code for all the script modules. For each module, there are two files:
- `xxx.pyx`: Python source code written in Cython, which can later be compiled into a `.c` file.
- `xxx.c`: The compiled version of the Cython extension module, which can later be compiled into `.pyd` binary source files.
The actual files that are imported and used are the `.pyd` files. I have uploaded the `.c` files that were generated with Cython, so it is not necessary to have Cython to recompile the existing extension modules. To build the Cython extensions, run:
python setup.py build_ext --inplace
By default, `setup.py` builds the extension from the `.pyx` files and falls back to the `.c` files if Cython is not installed. If you wish to build using the `.c` files (for example, to ensure that the build doesn't fail due to particular Cython version issues), you must set `USE_CYTHON=False` in `setup.py`.
To use this script, you can pip install it as follows:
pip install kb_macropy
Note that the package name for download is kb_macropy. However, to start the script, run `macropy`.
You can also clone this repository and simply run the `__main__.py` file, or install it by running:
python setup.py install
## Why did I write this script?
A lot of times I found myself repeating one or more tasks. Some of these tasks are tedious and may be performed more than one time a day. Other tasks may be faster if they are performed without interacting with GUI elements. Combine all this with my low-performance laptop and you can see why I have written this script.
## Description
This script can be described as a keyboard listener. However, unlike normal keyboard listeners provided by existing modules like `keyboard`, `pynput`, etc., this script has two huge advantages. The first is the ability to use any key combination for triggering a hotkey, and multiple key combinations can be specified easily to trigger the same hotkey. The second advantage is the ability to use any keyboard keys (even keys like `FN`) as long as the key is reported by the os.
This script relies heavily on windows API and focuses on tasks that involve windows explorer. These tasks are triggered by a hotkey. There is also support for word expansion where you type a colon followed by an abbreviation, and a substitution will be added accordingly.
## Features
<ins>Below are some of the windows explorer operations that the script can perform</ins>:
- Creating a new file -> `Ctrl + Shift + ['m' or 'M']`.
![Creating A New File](https://github.com/Ryen-042/Macropy/blob/main/Images/New_File.gif?raw=true)
- Copying the full path to the selected files in the active explorer/desktop window -> `Shift + F2`.
- Merging the selected images from the active explorer window into a PDF file -> `Ctrl + Shift + ['p' or 'P']`.
![Merging Images Into PDF](https://github.com/Ryen-042/Macropy/blob/main/Images/Merging_Images_To_PDF.gif?raw=true)
- Converting the selected word files from the active explorer window into PDF files -> `Backtick + ['o' or 'O']`.
- Converting the selected powerpoint files from the active explorer window into PDF files -> `Backtick + ['p' or 'P']`.
![Converting Powerpoint Files To PDF](https://github.com/Ryen-042/Macropy/blob/main/Images/Converting_Powerpoint_To_PDF.gif?raw=true)
- Reopening closed file explorer windows (currently only keeps track of closed explorers by `Alt + F4` or `Ctrl + W`).
![Reopening Closed Explorer](https://github.com/Ryen-042/Macropy/blob/main/Images/Reopening_Closed_Explorer.gif?raw=true)
- Converting `.mp3` audio files into `.wav` files.
- Flattening directories by moving all the files/folders inside to the same level.
<ins>Next are some of the supported window manipulation operations</ins>:
- Moving the window around (up, right, down, right) -> `Backtick + (↑ or → or ↓ or ←)`.
![Moving Window Around](https://github.com/Ryen-042/Macropy/blob/main/Images/Moving_Window.gif?raw=true)
- Making the window always on top -> `FN + Ctrl + ['a', 'A']`.
- Decreasing/increasing the opacity of a window -> `Backtick + (['+', '='] or ['-', '_'])`.
![Changing Opacity](https://github.com/Ryen-042/Macropy/blob/main/Images/Changing_Opacity.gif?raw=true)
<ins>Next are some of the supported system manipulation operations</ins>:
- Putting the device into sleep mode -> `Win + FN + Ctrl + ['s', 'S']`.
- Shutting down the system -> `Win + FN + Ctrl + ['q', 'Q']`.
- Increasing/Decreasing the system volume -> `Ctrl + Shift + (['=', '+'] Or ['-', '_'])`.
- Increasing/Decreasing brightness -> `Backtick + ('F2' Or 'F3')`.
- Sending hotkeys and keyboard key sequences.
- Scrolling up/down (by sending mouse wheel scrolls) -> While ScrLck is active: `W or A or S or D`.
<ins>Next are some of the supported text expansion operations</ins>:
- Expanding text (e.g., try pressing the next keys -> `:name`).
![Text Expansion](https://github.com/Ryen-042/Macropy/blob/main/Images/Expanding_Text.gif?raw=true)
- Opening a file or a folder (e.g., try pressing the next keys -> `!paint`).
![Opening Paint](https://github.com/Ryen-042/Macropy/blob/main/Images/Opening_Paint.gif?raw=true)
## Extra
- The script does not receive keyboard events when the active process is elevated. A notification message will be printed every 10 seconds with a sound when this happens. You can run the script with elevated privileges to receive keyboard events in this scenario.
![Elevated Process Checker](https://github.com/Ryen-042/Macropy/blob/main/Images/Elevated_Checker.png?raw=true)
- To terminate the script, press the hotkey -> `FN + ESC`.
- To make sure the script is running (by displaying a toast notification), press the hotkey -> `FN + /`.
- To clear the terminal, press the hotkey -> `Ctrl + FN + C`.
- To suppress/silence the terminal output, press the hotkey -> `FN + Alt + S`.
- To suppress keyboard keys (hotkeys still work), press the hotkey -> `Ctrl + Alt + D`.
- The script will not allow more than one active instance at a time.
Raw data
{
"_id": null,
"home_page": "https://github.com/Ryen-042/macropy",
"name": "kb-macropy",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "keyboard automation script",
"author": "Ahmed Tarek",
"author_email": "ahmedtarek4377@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/2c/5b/8cf6ee480afbfdb4cb2c848c472545bc27fd4b08ef75907757e28a1e2cfd/kb_macropy-0.0.24.tar.gz",
"platform": null,
"description": "# Macropy\nKeyboard listener, hotkey manager, word expander, task automation, and more!\n\n![Terminal Output](https://github.com/Ryen-042/Macropy/blob/main/Images/Output.png?raw=true)\n\n## Big Update - Cython\nCython is used to compile python source code and make it faster. Cython creates `.c` files that can be compiled into python binary extension modules.\n\nThe `macropy/cython_extensions` directory contains all the Cython code for all the script modules. For each module, there are two files:\n- `xxx.pyx`: Python source code written in Cython, which can later be compiled into a `.c` file.\n- `xxx.c`: The compiled version of the Cython extension module, which can later be compiled into `.pyd` binary source files.\n\nThe actual files that are imported and used are the `.pyd` files. I have uploaded the `.c` files that were generated with Cython, so it is not necessary to have Cython to recompile the existing extension modules. To build the Cython extensions, run:\n\n python setup.py build_ext --inplace\n\nBy default, `setup.py` builds the extension from the `.pyx` files and falls back to the `.c` files if Cython is not installed. If you wish to build using the `.c` files (for example, to ensure that the build doesn't fail due to particular Cython version issues), you must set `USE_CYTHON=False` in `setup.py`.\n\nTo use this script, you can pip install it as follows:\n\n pip install kb_macropy\n\nNote that the package name for download is kb_macropy. However, to start the script, run `macropy`.\n\nYou can also clone this repository and simply run the `__main__.py` file, or install it by running:\n\n python setup.py install\n\n## Why did I write this script?\nA lot of times I found myself repeating one or more tasks. Some of these tasks are tedious and may be performed more than one time a day. Other tasks may be faster if they are performed without interacting with GUI elements. Combine all this with my low-performance laptop and you can see why I have written this script.\n\n## Description\nThis script can be described as a keyboard listener. However, unlike normal keyboard listeners provided by existing modules like `keyboard`, `pynput`, etc., this script has two huge advantages. The first is the ability to use any key combination for triggering a hotkey, and multiple key combinations can be specified easily to trigger the same hotkey. The second advantage is the ability to use any keyboard keys (even keys like `FN`) as long as the key is reported by the os.\n\nThis script relies heavily on windows API and focuses on tasks that involve windows explorer. These tasks are triggered by a hotkey. There is also support for word expansion where you type a colon followed by an abbreviation, and a substitution will be added accordingly.\n\n## Features\n<ins>Below are some of the windows explorer operations that the script can perform</ins>:\n- Creating a new file -> `Ctrl + Shift + ['m' or 'M']`.\n\n![Creating A New File](https://github.com/Ryen-042/Macropy/blob/main/Images/New_File.gif?raw=true)\n\n- Copying the full path to the selected files in the active explorer/desktop window -> `Shift + F2`.\n\n- Merging the selected images from the active explorer window into a PDF file -> `Ctrl + Shift + ['p' or 'P']`.\n\n![Merging Images Into PDF](https://github.com/Ryen-042/Macropy/blob/main/Images/Merging_Images_To_PDF.gif?raw=true)\n\n- Converting the selected word files from the active explorer window into PDF files -> `Backtick + ['o' or 'O']`.\n\n- Converting the selected powerpoint files from the active explorer window into PDF files -> `Backtick + ['p' or 'P']`.\n\n![Converting Powerpoint Files To PDF](https://github.com/Ryen-042/Macropy/blob/main/Images/Converting_Powerpoint_To_PDF.gif?raw=true)\n\n- Reopening closed file explorer windows (currently only keeps track of closed explorers by `Alt + F4` or `Ctrl + W`).\n\n![Reopening Closed Explorer](https://github.com/Ryen-042/Macropy/blob/main/Images/Reopening_Closed_Explorer.gif?raw=true)\n\n- Converting `.mp3` audio files into `.wav` files.\n\n- Flattening directories by moving all the files/folders inside to the same level.\n\n<ins>Next are some of the supported window manipulation operations</ins>:\n- Moving the window around (up, right, down, right) -> `Backtick + (\u2191 or \u2192 or \u2193 or \u2190)`.\n\n![Moving Window Around](https://github.com/Ryen-042/Macropy/blob/main/Images/Moving_Window.gif?raw=true)\n\n- Making the window always on top -> `FN + Ctrl + ['a', 'A']`.\n\n- Decreasing/increasing the opacity of a window -> `Backtick + (['+', '='] or ['-', '_'])`.\n\n![Changing Opacity](https://github.com/Ryen-042/Macropy/blob/main/Images/Changing_Opacity.gif?raw=true)\n\n<ins>Next are some of the supported system manipulation operations</ins>:\n- Putting the device into sleep mode -> `Win + FN + Ctrl + ['s', 'S']`.\n\n- Shutting down the system -> `Win + FN + Ctrl + ['q', 'Q']`.\n\n- Increasing/Decreasing the system volume -> `Ctrl + Shift + (['=', '+'] Or ['-', '_'])`.\n\n- Increasing/Decreasing brightness -> `Backtick + ('F2' Or 'F3')`.\n\n- Sending hotkeys and keyboard key sequences.\n\n- Scrolling up/down (by sending mouse wheel scrolls) -> While ScrLck is active: `W or A or S or D`.\n\n<ins>Next are some of the supported text expansion operations</ins>:\n- Expanding text (e.g., try pressing the next keys -> `:name`).\n\n![Text Expansion](https://github.com/Ryen-042/Macropy/blob/main/Images/Expanding_Text.gif?raw=true)\n\n- Opening a file or a folder (e.g., try pressing the next keys -> `!paint`).\n\n![Opening Paint](https://github.com/Ryen-042/Macropy/blob/main/Images/Opening_Paint.gif?raw=true)\n\n## Extra\n- The script does not receive keyboard events when the active process is elevated. A notification message will be printed every 10 seconds with a sound when this happens. You can run the script with elevated privileges to receive keyboard events in this scenario.\n\n![Elevated Process Checker](https://github.com/Ryen-042/Macropy/blob/main/Images/Elevated_Checker.png?raw=true)\n\n- To terminate the script, press the hotkey -> `FN + ESC`.\n\n- To make sure the script is running (by displaying a toast notification), press the hotkey -> `FN + /`.\n\n- To clear the terminal, press the hotkey -> `Ctrl + FN + C`.\n\n- To suppress/silence the terminal output, press the hotkey -> `FN + Alt + S`.\n\n- To suppress keyboard keys (hotkeys still work), press the hotkey -> `Ctrl + Alt + D`.\n\n- The script will not allow more than one active instance at a time.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Keyboard listener and automation script.",
"version": "0.0.24",
"split_keywords": [
"keyboard",
"automation",
"script"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "538b3f18a35e63856c52f6146e538b081be8158c182aa2ec922bb3c58cb22a07",
"md5": "a873174bc25aad23e733227e0ea2eda2",
"sha256": "7086c28b3e030b2589cad86789ea4c87bbb420064a50974f6e7ffb61cd122f44"
},
"downloads": -1,
"filename": "kb_macropy-0.0.24-cp310-cp310-win_amd64.whl",
"has_sig": false,
"md5_digest": "a873174bc25aad23e733227e0ea2eda2",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": null,
"size": 1845009,
"upload_time": "2023-04-06T14:45:37",
"upload_time_iso_8601": "2023-04-06T14:45:37.593549Z",
"url": "https://files.pythonhosted.org/packages/53/8b/3f18a35e63856c52f6146e538b081be8158c182aa2ec922bb3c58cb22a07/kb_macropy-0.0.24-cp310-cp310-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1082c2e813f9163e186e9d90f8fbf940c5777f1c1c3246c1145d18ed07cc6849",
"md5": "3b6930e9cb86fc531afafe89a8802dd1",
"sha256": "0bdb51a121fa1fa2656e84a24782e36e228fc7af254d7fd9272071ed66601631"
},
"downloads": -1,
"filename": "kb_macropy-0.0.24-py3.10-win-amd64.egg",
"has_sig": false,
"md5_digest": "3b6930e9cb86fc531afafe89a8802dd1",
"packagetype": "bdist_egg",
"python_version": "0.0.24",
"requires_python": null,
"size": 1851805,
"upload_time": "2023-04-06T14:46:03",
"upload_time_iso_8601": "2023-04-06T14:46:03.275089Z",
"url": "https://files.pythonhosted.org/packages/10/82/c2e813f9163e186e9d90f8fbf940c5777f1c1c3246c1145d18ed07cc6849/kb_macropy-0.0.24-py3.10-win-amd64.egg",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2c5b8cf6ee480afbfdb4cb2c848c472545bc27fd4b08ef75907757e28a1e2cfd",
"md5": "bf9b23289cd2d0e3633743c1e4dc7a3c",
"sha256": "dffecb5890084e62aa42aabb02e41ccd6c33aaf731e707364d88df76252296bb"
},
"downloads": -1,
"filename": "kb_macropy-0.0.24.tar.gz",
"has_sig": false,
"md5_digest": "bf9b23289cd2d0e3633743c1e4dc7a3c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 1428611,
"upload_time": "2023-04-06T14:46:23",
"upload_time_iso_8601": "2023-04-06T14:46:23.536405Z",
"url": "https://files.pythonhosted.org/packages/2c/5b/8cf6ee480afbfdb4cb2c848c472545bc27fd4b08ef75907757e28a1e2cfd/kb_macropy-0.0.24.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-06 14:46:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "Ryen-042",
"github_project": "macropy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "img2pdf",
"specs": [
[
">=",
"0.4.4"
]
]
},
{
"name": "keyboard",
"specs": [
[
">=",
"0.13.5"
]
]
},
{
"name": "opencv_python",
"specs": [
[
">=",
"4.6.0.66"
]
]
},
{
"name": "Pillow",
"specs": [
[
">=",
"9.5.0"
]
]
},
{
"name": "psutil",
"specs": [
[
">=",
"5.9.4"
]
]
},
{
"name": "PyAudio",
"specs": [
[
">=",
"0.2.13"
]
]
},
{
"name": "pynput",
"specs": [
[
">=",
"1.7.6"
]
]
},
{
"name": "pyttsx3",
"specs": [
[
">=",
"2.90"
]
]
},
{
"name": "pywin32",
"specs": [
[
">=",
"305"
]
]
},
{
"name": "pyWinhook",
"specs": [
[
">=",
"1.6.2"
]
]
},
{
"name": "win11toast",
"specs": [
[
">=",
"0.32"
]
]
},
{
"name": "win32gui",
"specs": [
[
">=",
"221.6"
]
]
},
{
"name": "win32security",
"specs": [
[
">=",
"2.1.0"
]
]
},
{
"name": "WMI",
"specs": [
[
">=",
"1.5.1"
]
]
}
],
"lcname": "kb-macropy"
}