windows定时切换桌面背景图片(一)

环境声明

类别 Value
系统 windows 7/8/10
python版本 3.X
注意:
python 脚本路径: D:\scripts\change_windows_background_picture.py
bat windows 脚本路径:  D:\scripts\start_change_pic.bat

在这里插入图片描述

python 脚本路径: D:\scripts\change_windows_background_picture.py

import random
import ctypes
import time
import os

path = r"C:\Users\WIN10\Pictures"
while True:
    file = os.listdir(path);  # 打开存储图片文件夹中的图片目录
    filepath = path +"\\" + random.choice(file);  # 随机选取某张图片 ,图片完整路径
    ctypes.windll.user32.SystemParametersInfoW(20, 0, filepath, 0)  # 设置桌面壁纸
    time.sleep(30 * 60);  #每半小时更换一次

bat windows 脚本路径: D:\scripts\start_change_pic.bat

@echo off  
D:  
cd D:\WORKSPACE\test  
start python test.py  
exit  

设置windows开机启动
1 进入开机启动目录StartUp ,地址栏输入:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
2 把需要自动运行的脚本的快捷方式复制到StartUp目录
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_31024251/article/details/108534344