Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit b59cf31

Browse files
committed
chore: add manifest loader poc script
1 parent 90de25b commit b59cf31

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

scripts/cleanmanifestloader.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
from pathlib import Path
2+
from subprocess import run
3+
from tkinter import Label, Tk
4+
5+
from PIL import Image, ImageTk
6+
7+
8+
def get_powershell_output(command: str) -> str:
9+
process = run(command, capture_output=True, text=True, shell=True)
10+
return process.stdout.strip()
11+
12+
13+
def get_icon_name(app_name: str) -> Path:
14+
command = f"""powershell "(Get-AppxPackage -Name {app_name} | Get-AppxPackageManifest).package.properties.logo" """
15+
return Path(get_powershell_output(command))
16+
17+
18+
def get_install_path(app_name: str) -> Path:
19+
command = f"""powershell "(Get-AppxPackage -Name {app_name}).InstallLocation" """
20+
return Path(get_powershell_output(command))
21+
22+
23+
def locate_icon(icon: Path, install_path: Path) -> Path:
24+
matches = install_path.glob(f"**/{icon.stem}*.png")
25+
# usually 3 matches (default, black, white), let's use default
26+
return list(matches)[0]
27+
28+
29+
def show_icon(icon_path: Path) -> None:
30+
root = Tk()
31+
root.title("Display Icon")
32+
pil_image = Image.open(icon_path)
33+
tk_image = ImageTk.PhotoImage(pil_image)
34+
label = Label(root, image=tk_image)
35+
label.pack()
36+
root.mainloop()
37+
38+
39+
def main(current_name: str) -> None:
40+
icon_path = get_icon_name(current_name)
41+
print(icon_path)
42+
# Assets\CalculatorStoreLogo.png
43+
44+
install_path = get_install_path(current_name)
45+
print(install_path)
46+
# C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_11.2411.1.0_x64__8wekyb3d8bbwe
47+
48+
selected_icon = locate_icon(icon_path, install_path)
49+
print(selected_icon)
50+
# C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_11.2411.1.0_x64__8wekyb3d8bbwe\Assets\CalculatorStoreLogo.scale-200.png
51+
52+
show_icon(selected_icon)
53+
# see the proof
54+
55+
56+
if __name__ == "__main__":
57+
# Let's use "Microsoft.WindowsCalculator" as example.
58+
# Names can be listed by `Get-AppxPackage | Select-Object -ExpandProperty Name`
59+
main("Microsoft.WindowsStore")

0 commit comments

Comments
 (0)