python设置桌面壁纸_Python实现设置windows桌面壁纸代码分享

每天换一个壁纸,每天好心情。

# -*- coding: UTF-8 -*-

from __future__ import unicode_literals

import Image

import datetime

import win32gui,win32con,win32api

import re

from HttpWrapper import SendRequest

StoreFolder = "c:\\dayImage"

def setWallpaperFromBMP(imagepath):

k = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER,"Control Panel\\Desktop",0,win32con.KEY_SET_VALUE)

win32api.RegSetValueEx(k, "WallpaperStyle", 0, win32con.REG_SZ, "2") #2拉伸适应桌面,0桌面居中

win32api.RegSetValueEx(k, "TileWallpaper", 0, win32con.REG_SZ, "0")

win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER,imagepath, 1+2)

def setWallPaper(imagePath):

"""

Given a path to an image, convert it to bmp and set it as wallpaper

"""

bmpImage = Image.open(imagePath)

newPath = StoreFolder + '\\mywallpaper.bmp'

bmpImage.save(newPath, "BMP")

setWallpaperFromBMP(newPath)

def getPicture():

url = "http://photography.nationalgeographic.com/photography/photo-of-the-day/"

h = SendRequest(url)

if h.GetSource():

r = re.findall('

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值