壁纸轮播小工具

查看 69|回复 10
作者:Listentomusic   
壁纸轮播小工具,每xxx秒后自动切换壁纸;
新人练手,大佬勿喷!{:301_998:}
import os
import ctypes
from time import sleep
from random import randint
def map_storage(path):
    file_list = []
    picture_list = os.listdir(path)
    for line in picture_list:
        # 壁纸过滤 - 只保留图像文件格式
        try:
            if line.split('.')[1] == 'png' or line.split('.')[1] == 'jpeg' or line.split('.')[1] == 'jpg':
                file_list.append(path + '\\' + line)
        except:
            pass
    # print('壁纸总数:', len(file_list), '张')
    return file_list
def random_wallpaper(image_path):
    # 随机抽出一张壁纸
    image_path = image_path[randint(0, len(image_path) - 1)]
    # 设置壁纸
    ctypes.windll.user32.SystemParametersInfoW(20, 0, image_path, 3)
    print('设置成功...')
if __name__ == '__main__':
    user_path = input('请输入壁纸文件夹路径(绝对路径): ')
    file_path = map_storage(user_path)
    while True:
        # 设置定时切换壁纸
        random_wallpaper(file_path)
        sleep(5)

壁纸, 小工具

海是倒过来的天   

这个东西不是系统自带的吗
qfmy2024   


Listentomusic 发表于 2024-8-21 11:24
这个有自带嘛我不太清楚,闲来无事练习练习的

有待改进!比如用tk写个gui,可以点击选择目录,可以设置时间等,然后轮播保证每轮都能轮到
Listentomusic
OP
  


海是倒过来的天 发表于 2024-8-21 11:19
这个东西不是系统自带的吗

这个有自带嘛我不太清楚,闲来无事练习练习的
cpbjlwh   

好样的!学习学习
Zaof1   

学习了!不错的练手工具
A582168411   

谢谢分享
yzytom   

写的不错
freckle   


海是倒过来的天 发表于 2024-8-21 11:19
这个东西不是系统自带的吗

系统自带的只能选中最后一个目录,目录中还有目录就不行了,我用DisplayFusion,可以包含多个子目录。
aiguohou   

谢谢分享,刚好需要
您需要登录后才可以回帖 登录 | 立即注册

返回顶部