Skip to content

Commit 24e7054

Browse files
committed
Fix "Customize shortcut" dialog not showing up sometimes
1 parent 14be56f commit 24e7054

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

dialogs/customize_shortcut.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def show_change_icon_btn():
5353
if use_folder_icon.get():
5454
change_icon_btn.forget()
5555

56-
_icon = preferences.get_folder_icon(path)
56+
_icon = shortcut.get_folder_icon(path)
5757
update_icon(_icon[0], _icon[1])
5858
else:
5959
change_icon_btn.pack(side = "left")

utils/icon.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ctypes, shutil
1+
import ctypes, shutil, os
22
from io import BytesIO
33
from PIL import Image, IcoImagePlugin
44
from icoextract import IconExtractor
@@ -12,16 +12,16 @@ def pick_icon(window, initial_icon_file_path: str = "C:\\Windows\\System32\\shel
1212
ctypes.windll.kernel32.lstrcpyW(icon_file_buffer, initial_icon_file_path)
1313

1414
result = ctypes.windll.shell32.PickIconDlg(ctypes.windll.user32.GetParent(window.winfo_id()), icon_file_buffer, ctypes.sizeof(icon_file_buffer), ctypes.byref(icon_index))
15-
if result: return (icon_file_buffer.value, icon_index.value)
15+
if result: return (os.path.expandvars(icon_file_buffer.value), icon_index.value)
1616

1717

18-
def extract_icon(path: str, index: str) -> None:
18+
def extract_icon(path: str, index: int) -> None:
1919
if not path.endswith(".ico"):
2020
try:
2121
extractor = IconExtractor(path)
2222
extractor.export_icon(preferences.temp + "\\icon.ico", index)
2323
except:
24-
extractor = IconExtractor(path.replace("System32", "SystemResources") + ".mun")
24+
extractor = IconExtractor(path.lower().replace("system32", "systemresources") + ".mun")
2525
extractor.export_icon(preferences.temp + "\\icon.ico", index)
2626
else:
2727
shutil.copyfile(path, preferences.temp + "\\icon.ico")

utils/shortcut.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ def get_folder_icon(folder_path: str) -> str:
9696
_folder_icon_path_list.reverse()
9797
_folder_icon_index = int(_folder_icon_path_list[0])
9898

99-
_folder_icon = _folder_icon.lower().replace("," + str(_folder_icon_index), "")
99+
_folder_icon = _folder_icon.lower().removesuffix("," + str(_folder_icon_index))
100100

101-
folder_icon = (_folder_icon.replace("," + str(_folder_icon_index), ""), _folder_icon_index)
101+
folder_icon = (os.path.expandvars(_folder_icon), _folder_icon_index)
102102

103103
return folder_icon

0 commit comments

Comments
 (0)