Skip to content

Commit f227344

Browse files
Attemped fix for submenu
1 parent 28008d4 commit f227344

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

wormhole.exe

-1.54 KB
Binary file not shown.

wormhole.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -569,21 +569,23 @@ def register_context_menu(self):
569569
for ext in info['extensions']:
570570
main_key_path = rf"Software\Classes\SystemFileAssociations\{ext}\shell\WormholeConvert"
571571
key = winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, main_key_path, 0, winreg.KEY_SET_VALUE)
572-
winreg.SetValueEx(key, None, 0, winreg.REG_SZ, "Convert with Wormhole")
572+
winreg.SetValueEx(key, "MUIVerb", 0, winreg.REG_SZ, "Convert with Wormhole")
573573
winreg.SetValueEx(key, "Icon", 0, winreg.REG_SZ, icon_path)
574-
subcommands = []
575-
for tgt in info['targets']:
574+
winreg.SetValueEx(key, "SubCommands", 0, winreg.REG_SZ, "")
575+
# Create the shell subkey under main
576+
shell_key_path = main_key_path + r"\shell"
577+
winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, shell_key_path, 0, winreg.KEY_SET_VALUE)
578+
for i, tgt in enumerate(sorted(info['targets'])): # Sort for consistent order
576579
clean_tgt = tgt.replace(' ', '')
577-
subcommands.append(f"To{clean_tgt}")
578-
sub_key_path = rf"Software\Classes\SystemFileAssociations\{ext}\shell\To{clean_tgt}"
580+
sub_key_name = f"{i:02d}_{clean_tgt}" # Prefix for ordering
581+
sub_key_path = shell_key_path + rf"\{sub_key_name}"
579582
sub_key = winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, sub_key_path, 0, winreg.KEY_SET_VALUE)
580583
winreg.SetValueEx(sub_key, None, 0, winreg.REG_SZ, f"To {tgt}")
581584
winreg.CloseKey(sub_key)
582585
cmd_key_path = sub_key_path + r"\command"
583586
cmd_key = winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, cmd_key_path, 0, winreg.KEY_SET_VALUE)
584587
winreg.SetValueEx(cmd_key, None, 0, winreg.REG_SZ, f'{exe_path} "%1" "{tgt}"')
585588
winreg.CloseKey(cmd_key)
586-
winreg.SetValueEx(key, "SubCommands", 0, winreg.REG_SZ, "|".join(subcommands))
587589
winreg.CloseKey(key)
588590
except Exception as e:
589591
print(f"Failed to register context menu: {e}")
@@ -595,10 +597,11 @@ def unregister_context_menu(self):
595597
for ext in info['extensions']:
596598
main_key_path = rf"Software\Classes\SystemFileAssociations\{ext}\shell\WormholeConvert"
597599
self._delete_registry_key(winreg.HKEY_CURRENT_USER, main_key_path)
600+
# Also clean up old flat structure if exists
598601
for tgt in info['targets']:
599602
clean_tgt = tgt.replace(' ', '')
600-
sub_key_path = rf"Software\Classes\SystemFileAssociations\{ext}\shell\To{clean_tgt}"
601-
self._delete_registry_key(winreg.HKEY_CURRENT_USER, sub_key_path)
603+
old_sub_key_path = rf"Software\Classes\SystemFileAssociations\{ext}\shell\To{clean_tgt}"
604+
self._delete_registry_key(winreg.HKEY_CURRENT_USER, old_sub_key_path)
602605
except Exception as e:
603606
print(f"Failed to unregister context menu: {e}")
604607

0 commit comments

Comments
 (0)