Skip to content

Commit

Permalink
Merge pull request #40 from saalaus/master
Browse files Browse the repository at this point in the history
Fix file extension, add DESKTOP type for windows context menu
  • Loading branch information
saleguas authored Apr 11, 2024
2 parents 2934047 + 963a605 commit ee3ccbf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ can reference this table to determine the `type`:
| DIRECTORY | HKEY_CURRENT_USER\\Software\\Classes\\Directory\\shell | Opens on a directory |
| DIRECTORY_BACKGROUND | HKEY_CURRENT_USER\\Software\\Classes\\Directory\\Background\\shell | Opens on the background of the Directory |
| DRIVE | HKEY_CURRENT_USER\\Software\\Classes\\Drive\\shell | Opens on the drives(think USBs) |
| DESKTOP | Software\\Classes\\DesktopBackground\\shell | Opens on the background of the desktop |

* * *

Expand Down
3 changes: 2 additions & 1 deletion context_menu/windows_menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ def delete_key(path: str, hive: int = 0) -> None:
# These are the paths in the registry that correlate to when the context menu is fired.
# For example, FILES is when a file is right clicked
CONTEXT_SHORTCUTS = {
"FILELOC": "Software\\Classes",
"FILELOC": "Software\\Classes\\SystemFileAssociations",
"FILES": "Software\\Classes\\*\\shell",
"DIRECTORY": "Software\\Classes\\Directory\\shell",
"DIRECTORY_BACKGROUND": "Software\\Classes\\Directory\\Background\\shell",
"DRIVE": "Software\\Classes\\Drive\\shell",
"DESKTOP": "Software\\Classes\\DesktopBackground\\shell",
}

# Not used yet, but could be useful in the future
Expand Down
11 changes: 10 additions & 1 deletion tests/test_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ def test_context_menu(windows_platform: None, mocked_winreg: MockedWinReg) -> No
sys.executable, Path(__file__).parent.as_posix()
),
),
# Test with DESKTOP
(
"DESKTOP",
{"python": foo},
"Software\\Classes\\DesktopBackground\\shell",
'''"{}" -c "import sys; sys.path.insert(0, '{}'); import test_windows; test_windows.foo([' '.join(sys.argv[1:]) ],'')" "%1"'''.format(
sys.executable, Path(__file__).parent.as_posix()
),
),
),
)
def test_context_command(
Expand Down Expand Up @@ -127,7 +136,7 @@ def test_context_command(
(
".txt",
{"command": "echo hello"},
"Software\\Classes\\.txt\\shell",
"Software\\Classes\\SystemFileAssociations\\.txt\\shell",
"echo hello",
),
),
Expand Down

0 comments on commit ee3ccbf

Please sign in to comment.