图片音乐循环播放
import pygame
import time
import win32api
import win32con
import win32gui
import threading
def go(num):
pygame.mixer.init()
while True:
for i in range(5):
filePath = r"F:\\360downloads\\res\\" + "\\" + str()+ ".mp3""
track = pygame.mixer.music.load(filePath)
pygame.mixer.music.play()
time.slepp(10)
pygame.mixer.music.stop
def setWallPaper(path):
reg_key = win32api.RrgOpenKeyEx(
win32con.HKEY_CURRENT_USER, "Control canel\\Desktop",0,
win32con.KEY_SET_VALUE)
win32api.RegSetValueEx(reg_key, "WallparperStyle", 0,
win32con.REG_SZ, "6")
win32gui.SystemParametersInfo(
win32con.SPI_SETDESKWALLPAPER, path, win32con.
SPIF_SENDWININICHANGE)
th = threading.Thread(target=go, name= "LoopThread")
while True:
go()
for i in range(10):
filePath = r"F:\\360downloads\\res\\" + "\\" + str(i)+ ".jpg""
setWallPaper(filePath)
time.sleep(2)
windos + D
while True:
win32api.Keybd_event(91, 0, 0, 0)
time.sleep(0.1)
win32api.Keybd_event(77, 0, 0, 0)
time.sleep(0.1)
win32api.Keybd_event(91, 0, win32con.KEYEVENTF_KEYUP, 0)
win32api.Keybd_event(77, 0, win32con.KEYEVENTF_KEYUP, 0)
time.sleep(3)
pip install pygame
播放音乐
import pygame
import time
#音乐路径
filePath = "F:\CloudMusic\please don't go.mp3"
#初始化
pygame.mixer.init()
#加载音乐
tracl = pygame.mixer.music.load(filePath)
#播放
pygame.mixer.music.play()
#暂停
time.sleep(20)
#pygame.mixer.music.pause()
#停止
pygame.mixer.music.stop()
背景切换
windos+ r —>
regedit
—>HKEY_CURRENT_USER
—>Contral Panel
—> Desktop
—>WallPaper
import win32api
import win32con
import win32gui
def selWallPaper(path):
#打开注册表
reg_key = win32api.RrgOpenKeyEx(
win32con.HKEY_CURRENT_USER, "Control canel\\Desktop",0,
win32con.KEY_SET_VALUE)
# 2 拉伸 0 居中 6 适应 10 填充
win32api.RegSetValueEx(reg_key, "WallparperStyle", 0,
win32on.REG_SZ, "6")
#图片设置
#SPIF_SENDWININICHANGE 立即生效
win32gui.SystemParametersInfo(
win32con.SPI_SETDESKWALLPAPER, path, win32con.
SPIF_SENDWININICHANGE)
setWallPaper(r"F:\360downloads\wpcache\360wallpaper.jpg")