-
Notifications
You must be signed in to change notification settings - Fork 3
/
DesktopWallpaperChanger.py
49 lines (44 loc) · 1.31 KB
/
DesktopWallpaperChanger.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import ctypes
import os
import time
from pynput.keyboard import Key,Controller
import Bing
def closeTerminal():
keyboard=Controller()
keyboard.press(Key.alt)
keyboard.press(Key.f4)
keyboard.release(Key.alt)
keyboard.release(Key.f4)
def changeWallpaper(image_path):
start=time.time()
end=time.time()
while True:
for dirname,dirnames,filenames in os.walk(image_path):
for file_name in filenames:
if (end-start)//3600 > 6:
try:
Bing.wallpaper_of_the_day(image_path)
start=time.time()
except:
pass
if file_name.endswith('.png') or file_name.endswith('.jpg'):
image=os.path.join(image_path,dirname,file_name)
SPI_SETDESKTOPWALLPAPER=20
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKTOPWALLPAPER,0,image,3)
time.sleep(30)
end=time.time()
def main():
closeTerminal()
#configure own folder
image_path = r'D:\Wallpapers'
try:
os.makedirs(image_path)
except:
pass
try:
Bing.wallpaper_of_the_day(image_path)
except:
pass
changeWallpaper(image_path)
if __name__=='__main__':
main()