{"id":24659960,"url":"https://github.com/offerrall/windowscontextmenu","last_synced_at":"2026-05-16T09:34:30.760Z","repository":{"id":166133350,"uuid":"626650952","full_name":"offerrall/WindowsContextMenu","owner":"offerrall","description":"WindowsContextMenu is a Python library that simplifies the process of creating and managing context menu entries in Windows","archived":false,"fork":false,"pushed_at":"2023-06-08T00:46:16.000Z","size":85,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-08T16:02:55.191Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/offerrall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-11T22:35:02.000Z","updated_at":"2023-08-16T18:10:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"dfcd86e5-1448-4c7c-bda4-1982efa1995e","html_url":"https://github.com/offerrall/WindowsContextMenu","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/offerrall/WindowsContextMenu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offerrall%2FWindowsContextMenu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offerrall%2FWindowsContextMenu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offerrall%2FWindowsContextMenu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offerrall%2FWindowsContextMenu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/offerrall","download_url":"https://codeload.github.com/offerrall/WindowsContextMenu/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offerrall%2FWindowsContextMenu/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33096963,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-26T03:15:30.092Z","updated_at":"2026-05-16T09:34:30.753Z","avatar_url":"https://github.com/offerrall.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WindowsContextMenu\n\nWindowsContextMenu is a Python library for creating and managing context menu items in Windows.\n\nThis library provides a simple and intuitive API for creating context menu items for files and folders in Windows. It supports creating simple commands and nested menus, as well as listing and removing existing items.\n\nThis library was created for personal use but is shared in the hopes that it may be useful to others or inspire contributions. Contributions are welcome via pull requests or issues.\n\n## Installation\n\nUse pip to install the library. The library does not require additional dependencies.\n\n```bash\npip install WindowsContextMenu\n```\n\n## Main Features\n- `Create commands`: This feature allows you to add custom commands to the context menu for files and directories.\n- `Create folders`: This feature enables you to organize your custom commands by creating nested folders in the context menu.\n- `Remove items`: Remove custom commands and folders from the context menu.\n- `Check existence`: Check if a command or folder already exists in the context menu.\n- `Get command`: Get the command associated with a specific item in the context menu.\n- `List items`: List all folders and commands in the context menu.\n- `Determine item type`: Check if an item in the context menu is a folder or a command.\n- `Get available scopes`: List all available scopes for the context menu, such as \"FILES\" and \"DIRECTORY\".\n\n## Windows Versions\n\nThis library is compatible with Windows 7, 8, 8.1 and 10.\nWindows 11 is compatible if remove the new w11 menu context.\n\n## Scopes\n\nIn Windows, a context menu can have different scopes depending on where it is displayed. The available scopes are:\n\n- `FILES`: for context menus displayed when right-clicking on a file.\n- `DIRECTORY`: for context menus displayed when right-clicking on a folder.\n- `DIRECTORY_BACKGROUND`: for context menus displayed when right-clicking on the background of a folder.\n- `DRIVE`: for context menus displayed when right-clicking on a drive.\n- `EXTENSION_SFA_\u003cextension\u003e`: for context menus displayed when right-clicking on a file with a specific extension.\n- `RECYCLE_BIN`: for context menus displayed when right-clicking on the Recycle Bin.\n- `DESKTOP`: for context menus displayed when right-clicking on the desktop.\n\nPaths in the registry for the different scopes:\n- `FILES`: `HKEY_CURRENT_USER\\*\\shell`\n- `DIRECTORY`: `HKEY_CURRENT_USER\\Software\\Classes\\Directory\\Background\\shell`\n- `DIRECTORY_BACKGROUND`: `HKEY_CURRENT_USER\\Software\\Classes\\Directory\\Background\\shell`\n- `DRIVE`: `HKEY_CURRENT_USER\\Software\\Classes\\Drive\\shell`\n- `EXTENSION_SFA_\u003cextension\u003e`: `HKEY_LOCAL_MACHINE\\Software\\Classes\\SystemFileAssociations\\{extension}\\shell`\n- `RECYCLE_BIN`: `HKEY_CLASSES_ROOT\\CLSID\\{645FF040-5081-101B-9F08-00AA002F954E}\\shell`\n- `DESKTOP`: `HKEY_CLASSES_ROOT\\DesktopBackground\\Shell\\`\t\n\nThe `get_available_scopes()` function can be used to get a list of all available scopes. The scope parameter is used in various functions to specify where the context menu items should be created or removed.\n\n## Usage\n\nAll Examples and API documentation can be found in the [Doc](https://offerrall.github.io/WindowsContextMenu/WindowsContextMenu.html).\nLittle example:\n\n```python\n\nfrom WindowsContextMenu.menu_operations import create_simple_command, mkdir_menu_context, get_available_scopes\n\n# List all available scopes for the context menu\nscopes = get_available_scopes()\n\n# Create a simple command in the context menu for all files\ncreate_simple_command(\"FILES\", \"Open with Notepad\", \"notepad.exe %1\")\n\n# Create a simple command in the context menu for directories\ncreate_simple_command(\"DIRECTORY\", \"Open Command Prompt Here\", \"cmd.exe /k cd %1\")\n\n# Create a folder in the context menu for all files\nmkdir_menu_context(\"FILES\", \"My Custom Commands\")\n\n# Create a command inside the previously created folder\ncreate_simple_command(\"FILES\", \"Custom Command 1\", \"cmd.exe /k echo Custom Command 1\", parent=\"My Custom Commands\")\n\n# Create a Folder inside the previously created folder\nmkdir_menu_context(\"FILES\", \"My Subfolder\", parent=\"My Custom Commands\")\n\n# Create a command inside the previously created subfolder\ncreate_simple_command(\"FILES\", \"Custom Command 2\", \"cmd.exe /k echo Custom Command 2\", parent=\"My Custom Commands/My Subfolder\")\n\n```\n\n## Special Variables in Windows Context Menu\n\nIn the context of Windows context menus, certain special variables, also known as \"command argument variables\", can be used to refer to different paths and items. Here, we will explain some of the most commonly used ones:\n\n### `%1` or `%L`\n\nThese variables refer to the full path of the file or folder that you have right-clicked on. When you create a command like `\"notepad.exe %1\"`, the `%1` will be replaced by the path of the file or folder that you right-clicked on.\n\n### `%V`\n\nThis variable refers to the selected item's folder path. It is most often used in conjunction with the `DIRECTORY_BACKGROUND` scope, where the right-click does not happen on a specific file or folder but in the background of a directory.\n\n### `%W`\n\nThis variable is used to get the working directory when the command is executed.\n\n### `SystemFolder`\n\nThis variable can be used to refer to system folders such as \"Desktop\", \"My Documents\", \"Program Files\", etc.\n\n### `AppData`\n\nThis variable can be used to refer to the current user's AppData folder.\n\n### `ProgramFiles`\n\nThis variable can be used to refer to the Program Files directory.\n\nNote: These variables can be combined to refer to more complex paths. For example, `\"%SystemFolder%\\My Documents\"` refers to the My Documents folder in the system folder.\n\n\n\n## Considerations for using WindowsContextMenu\n\nWhen using the WindowsContextMenu library, there are some important considerations to keep in mind:\n\n1. **Icon format**: The icons used for the context menu items must be in `.ico` format. Additionally, once the icon is assigned, it should not be deleted or moved from its original location. For instance, if you have an icon named `my_icon.ico`, it should persist in its current path even after its use.\n\n2. **Path formatting**: Paths used in the library, especially for specifying parent and child folders, must follow the Unix (or Linux) path format, i.e., `/ParentFolder/ChildFolder`. The use of backslashes `\\` common in Windows paths is not accepted.\n\n3. **Pre-existing parent folder**: Before you can create a child folder under a parent folder, the parent folder must already exist in the context menu. If you want to create a folder named `ChildFolder` inside `ParentFolder`, `ParentFolder` should already be present in your context menu.\n\n\n4. **Error handling**: The library functions are designed to throw a `WindowsError` exception when any error occurs during their execution. These exceptions can be caught and handled in your code to manage errors and provide appropriate feedback.\n\nRemember, understanding and following these considerations can help you avoid common mistakes and make the most of the WindowsContextMenu library.\n\n\n## TODO\n- Add support for other scopes.\n  - New Menu\n  - Send To\n  - Open With\n  - win+X\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofferrall%2Fwindowscontextmenu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fofferrall%2Fwindowscontextmenu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofferrall%2Fwindowscontextmenu/lists"}