1- import ctypes , shutil
1+ import ctypes , shutil , os
22from io import BytesIO
33from PIL import Image , IcoImagePlugin
44from 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" )
0 commit comments