|
| 1 | +# PyContextMenu: Add Python Scripts to the Windows Context Menu ⚙️ |
| 2 | + |
| 3 | +PyContextMenu allows you to easily add Python scripts to the Windows context menu (right-click menu) for files, folders, and the desktop background. |
| 4 | + |
| 5 | +## Functionality |
| 6 | + |
| 7 | +`PyContextMenu.py` handles both installing the main context menu entry and adding individual Python scripts to it. It uses command-line arguments to determine its function. |
| 8 | + |
| 9 | +## Installation and Usage |
| 10 | + |
| 11 | +1. Clone the repository: |
| 12 | + ```bash |
| 13 | + git clone [https://github.com/pablo-s-dev/PyContextMenu.git](https://github.com/pablo-s-dev/PyContextMenu.git) |
| 14 | + ``` |
| 15 | + |
| 16 | +2. Navigate to the project directory: |
| 17 | + ```bash |
| 18 | + cd PyContextMenu |
| 19 | + ``` |
| 20 | + |
| 21 | +3. **To install the main "PyContextMenu" entry:** |
| 22 | + ```bash |
| 23 | + python PyContextMenu.py |
| 24 | + ``` |
| 25 | + (Run without any additional arguments.) |
| 26 | + |
| 27 | +4. **To add a Python script to the context menu:** |
| 28 | + |
| 29 | +There are two ways to add a Python script to the context menu: |
| 30 | + |
| 31 | +### Method 1: Using the PyContextMenu Entry in the Context Menu |
| 32 | + |
| 33 | +1. Right-click on the Python script you want to add. |
| 34 | + |
| 35 | +2. Select "PyContextMenu" -> "Add this py script to the context menu of". |
| 36 | + |
| 37 | +3. Choose the desired location(s) for the context menu entry (files, folders, background, or all). |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +### Method 2: Using the Command Line |
| 43 | + |
| 44 | +1. Open a command prompt or PowerShell window. |
| 45 | + |
| 46 | +2. Navigate to the project directory. |
| 47 | + |
| 48 | +3. Run the script with the following command-line arguments: |
| 49 | + |
| 50 | + ```bash |
| 51 | + python PyContextMenu.py "C:\path\to\your\script.py" [option] |
| 52 | + ``` |
| 53 | + |
| 54 | + * `"C:\path\to\your\script.py"`: The absolute path to the Python script. Use double quotes, especially if the path contains spaces. |
| 55 | + * `[option]`: Specifies where the context menu entry should appear: |
| 56 | + * `--files`: For all files. |
| 57 | + * `--folders`: For folders. |
| 58 | + * `--background`: For the folder/desktop background. |
| 59 | + * `--all`: For all three (files, folders, and background). |
| 60 | + |
| 61 | +**Example:** |
| 62 | + |
| 63 | +```bash |
| 64 | +python PyContextMenu.py "C:\My Scripts\my_script.py" --all |
| 65 | +``` |
| 66 | + |
| 67 | + |
| 68 | +## How to Use Your Scripts |
| 69 | + |
| 70 | +After adding a script, right-click on a file, folder, or the background and select "[Your script name]". |
| 71 | +The script will be executed using the Python interpreter that it is in your path. |
| 72 | +
|
| 73 | +## Important Considerations |
| 74 | +
|
| 75 | + * **Path argument:** Your Python Scripts will receive the path of the folder/file clicked as the second argument. |
| 76 | +
|
| 77 | +## Contributing |
| 78 | +
|
| 79 | +Contributions are welcome! Please open an issue or submit a pull request. |
0 commit comments