A piece of online viewing is fun.CodeUse python to set Windows desktop.
Original http://seasons.javaeye.com/blog/60294
This is a python snippet to set wallpaper as the photo of the day in National Geographic.
1. Install Python form http://www.python.org/download/
2. Install Python Image Library (PLI) from http://www.pythonware.com/products/pil/
3. Say the code below and run it by Python
Python code
"""
Set the wallpaper as the picture got from National Geographic picture of the day
By seasons@gmail.com
"""
Import ctypes
Import image
Import calendar
Import urllib
Import socket
Storedir = 'C:/lg_wallpaper/pod /'
Def setwallpaperfrombmp (ImagePath ):
Spi_set1_wallpaper = 20 # accordingHttp://support.microsoft.com/default.aspx? SCID = 1, 97142
# Note that this statement
Ctypes. Windll. user32.systemparametersinfoa (spi_set1_wallpaper, 0, ImagePath, 0) # spif_updateinifile | spif_sendwininichange
Def setwallpaper (ImagePath ):
"Given a path to an image, convert it to BMP and set it as Wallpaper """
BMP image = image. Open (ImagePath)
Newpath = storedir + 'mywallpaper.bmp'
BMP image. Save (newpath, "BMP ")
Setwallpaperfrombmp (newpath)
Def getpicture (fname ):
Sock = urllib. urlopen ("http://lava.nationalgeographic.com/pod/index.html ")
Htmlsource = sock. Read ()
Sock. Close ()
Pos1 = htmlsource. Find ('sm _ wallpaper ')
Pos2 = htmlsource. Find ('/pod/pictures/normal ')
Filename = htmlsource [pos1 + 13: pos2-12]
Fileurl = 'HTTP: // lava.nationalgeographic.com/pod/pictures/lg_wallpaper/'{filename
Urllib. urlretrieve (fileurl, fname)
Print 'got the picture from '+ fileurl
Def setwallpaperoftoday ():
Filename = storedir + STR (calendar. datetime. Date. Today () + '.jpg'
Print filename
Getpicture (filename)
Setwallpaper (filename)
Setwallpaperoftoday ()
Print 'wallpaper set OK! '