-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWallPaper.py
More file actions
25 lines (20 loc) · 1 KB
/
Copy pathWallPaper.py
File metadata and controls
25 lines (20 loc) · 1 KB
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
import struct
import ctypes
import os
class ChangeWallPaper:
def __init__(self,PATH):
self.WALLPAPER_PATH = PATH
def is_64_windows(self):
"""Find out how many bits is OS. """
return 'PROGRAMFILES(X86)' in os.environ
def get_sys_parameters_info(self):
"""Based on if this is 32bit or 64bit returns correct version of SystemParametersInfo function. """
return ctypes.windll.user32.SystemParametersInfoW if self.is_64_windows() \
else ctypes.windll.user32.SystemParametersInfoA
def change_wallpaper(self):
print('change_wallpaper: %s'%self.WALLPAPER_PATH)
SPI_SETDESKWALLPAPER = 20
sys_parameters_info = self.get_sys_parameters_info()
r = sys_parameters_info(SPI_SETDESKWALLPAPER, 0, self.WALLPAPER_PATH, 3)
if not r: # When the SPI_SETDESKWALLPAPER flag is used, SystemParametersInfo returns TRUE unless there is an error (like when the specified file doesn't exist).
print(ctypes.WinError())