-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
60 lines (46 loc) · 2.78 KB
/
install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
if __name__ == '__main__':
import sys
from pathlib import Path
from winreg import HKEYType, REG_SZ, CreateKey, SetValueEx, HKEY_CLASSES_ROOT
from winotify import Notification
frozen: bool = hasattr(sys, 'frozen')
location: Path = Path(sys.executable).parent if frozen else Path(__file__).parent
main: str = 'Organizer.exe' if frozen else 'organizer.py'
command: str = f'"{str(location.joinpath(main))}" "%V"' if frozen \
else f'python "{str(location.joinpath(main))}" "%V"'
class Icons:
MASTER: str = str(location.joinpath("Master.ico"))
ORGANIZER: str = str(location.joinpath("Icon.ico"))
master_key_path: Path = Path(r'Directory\\Background\\shell\\Pietrodev')
master_key: HKEYType = CreateKey(HKEY_CLASSES_ROOT, str(master_key_path))
SetValueEx(master_key, 'MUIVerb', 0, REG_SZ, 'Pietrodev')
SetValueEx(master_key, 'subcommands', 0, REG_SZ, '')
SetValueEx(master_key, 'SeparatorAfter', 0, REG_SZ, '')
SetValueEx(master_key, 'SeparatorBefore', 0, REG_SZ, '')
SetValueEx(master_key, 'Icon', 0, REG_SZ, Icons.MASTER)
master_key_path_shell: Path = master_key_path.joinpath('shell')
master_key_shell: HKEYType = CreateKey(HKEY_CLASSES_ROOT, str(master_key_path_shell))
organizer_key_path: Path = master_key_path_shell.joinpath('Organizer')
organizer_key: HKEYType = CreateKey(HKEY_CLASSES_ROOT, str(organizer_key_path))
SetValueEx(organizer_key, 'MUIVerb', 0, REG_SZ, 'Organizer')
SetValueEx(organizer_key, 'subcommands', 0, REG_SZ, '')
SetValueEx(organizer_key, 'Icon', 0, REG_SZ, Icons.ORGANIZER)
organizer_shell_key_path: Path = organizer_key_path.joinpath('shell')
organizer_shell_key: HKEYType = CreateKey(HKEY_CLASSES_ROOT, str(organizer_shell_key_path))
organize_key_path: Path = organizer_shell_key_path.joinpath('Organize')
organize_key: HKEYType = CreateKey(HKEY_CLASSES_ROOT, str(organize_key_path))
SetValueEx(organize_key, 'MUIVerb', 0, REG_SZ, 'Organize')
organize_command_key_path: Path = organize_key_path.joinpath('command')
organize_command_key: HKEYType = CreateKey(HKEY_CLASSES_ROOT, str(organize_command_key_path))
SetValueEx(organize_command_key, '', 0, REG_SZ, command)
settings_key_path: Path = organizer_shell_key_path.joinpath('Settings')
settings_key: HKEYType = CreateKey(HKEY_CLASSES_ROOT, str(settings_key_path))
SetValueEx(settings_key, 'MUIVerb', 0, REG_SZ, 'Settings...')
settings_command_key_path: Path = settings_key_path.joinpath('command')
settings_command_key: HKEYType = CreateKey(HKEY_CLASSES_ROOT, str(settings_command_key_path))
SetValueEx(settings_command_key, '', 0, REG_SZ, rf'"{str(location.joinpath("config.json"))}"')
Notification(
app_id = 'Pietrodev', title = 'Organizer',
msg = 'Organizer has been installed. Please do not move the containing folder, icons can stop working.',
icon = location.joinpath("Icon.ico")
).show()