Toolbox for analyzing and editing pkg application files for psp,ps3, ps4 and ps5, includes the most useful functions you might need.
| 1 | import os |
| 2 | import sys |
| 3 | |
| 4 | if sys.platform == "win32": |
| 5 | import winreg |
| 6 | import ctypes |
| 7 | else: |
| 8 | winreg = None |
| 9 | ctypes = None |
| 10 | import tempfile |
| 11 | from enum import Enum |
| 12 | |
| 13 | class Style(Enum): |
| 14 | Tiled = 0 |
| 15 | Centered = 1 |
| 16 | Stretched = 2 |
| 17 | |
| 18 | class Wallpaper: |
| 19 | SPI_SETDESKWALLPAPER = 20 |
| 20 | SPIF_UPDATEINIFILE = 0x01 |
| 21 | SPIF_SENDWININICHANGE = 0x02 |
| 22 | |
| 23 | @staticmethod |
| 24 | def set(style: Style): |
| 25 | if sys.platform != "win32": |
| 26 | return |
| 27 | path = os.path.join(tempfile.gettempdir(), "Saved image", "wallpaper.JPG") |
| 28 | |
| 29 | # Assicurarsi che la directory esista |
| 30 | os.makedirs(os.path.dirname(path), exist_ok=True) |
| 31 | |
| 32 | key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Control Panel\Desktop", 0, winreg.KEY_SET_VALUE) |
| 33 | if style == Style.Stretched: |
| 34 | winreg.SetValueEx(key, "WallpaperStyle", 0, winreg.REG_SZ, "2") |
| 35 | winreg.SetValueEx(key, "TileWallpaper", 0, winreg.REG_SZ, "0") |
| 36 | elif style == Style.Centered: |
| 37 | winreg.SetValueEx(key, "WallpaperStyle", 0, winreg.REG_SZ, "1") |
| 38 | winreg.SetValueEx(key, "TileWallpaper", 0, winreg.REG_SZ, "0") |
| 39 | elif style == Style.Tiled: |
| 40 | winreg.SetValueEx(key, "WallpaperStyle", 0, winreg.REG_SZ, "1") |
| 41 | winreg.SetValueEx(key, "TileWallpaper", 0, winreg.REG_SZ, "1") |
| 42 | winreg.CloseKey(key) |
| 43 | |
| 44 | ctypes.windll.user32.SystemParametersInfoW( |
| 45 | Wallpaper.SPI_SETDESKWALLPAPER, |
| 46 | 0, |
| 47 | path, |
| 48 | Wallpaper.SPIF_UPDATEINIFILE | Wallpaper.SPIF_SENDWININICHANGE |
| 49 | ) |
| 50 | |
| 51 | |
| 52 |