Results 1 to 5 of 5

Thread: [Python] Random desktop background chooser

  1. #1
    Join Date
    Jan 2007
    Posts
    131
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default [Python] Random desktop background chooser

    Windows only.
    Run this at startup and it chooses a random desktop background from a folder. Allows you to cycle through them as well if you dont like the one chosen.

    Needs:
    -Python 2.5.4
    -PIL (for the converter script only) = http://effbot.org/downloads/PIL-1.1.6.win32-py2.5.exe
    -A brain

    Also here is a converter script to convert all image files to jpeg, so they can be set as the background:
    python Code:
    # Some help from [url]http://www.velocityreviews.com/forums/t339757-convert-all-images-to-jpeg.html[/url]

    # Input folder
    path = 'C:\Users\Tom\Pictures\Images'
    # Output folder
    opath = 'C:\Users\Tom\Pictures\jpgs'

    import glob
    import Image
    import os

    file_list = glob.glob(path+'\*.*')

    for image in file_list:
        try:
            out_path = os.path.split(image)[1].split('.')[0]
            Image.open(image).convert('RGB').save(opath+'\\'+out_path+'.jpg','JPEG')
            print 'Converting to '+opath+'\\'+out_path+'.jpg'
        except Exception,e:
            print e
    Here is the changer code:
    python Code:
    # Change the desktop background to something random
    import ctypes
    import sys
    import glob
    import random

    path = r'C:\Users\Tom\Pictures\jpgs'

    silent = False

    # Change the shit
    def set_wallpaper():
        files  = glob.glob(path+'\*.jpg')
        choice = random.choice(files)
        if not silent:
            print 'File %s chosen'%choice
        cs = ctypes.c_buffer(choice)
        b = ctypes.windll.user32.SystemParametersInfoA(20 ,1, cs, 1)
       
    set_wallpaper()

    if not silent:
        print 'Enter "1" to cycle through backgrounds'
        if not raw_input() == "1":
            sys.exit()
        print 'Press enter to change it again'
        while True:
            raw_input()
            set_wallpaper()
    Last edited by bobng; 05-25-2009 at 11:07 PM.

  2. #2
    Join Date
    May 2007
    Location
    UK
    Posts
    4,007
    Mentioned
    1 Post(s)
    Quoted
    12 Post(s)

    Default

    Nice
    Cheers for making and sharing.

    T~M

  3. #3
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Windows 7 already has this feature
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  4. #4
    Join Date
    Nov 2006
    Location
    Wisconsin
    Posts
    1,629
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    XP Powertoys are fun. Anyways looks nice, although I am not trying it as I already have it handled.


    Quote Originally Posted by Rubix View Post
    Quote Originally Posted by Dan Cardin View Post
    you ought to listen to Mr. Klean...he's magical!
    this.

  5. #5
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Windows 7 copy cats everything, and gives developers no job, bad times, bad times...

    Atm, you made some nice code, I am about to maybe, might, could, might, maybe, learn python too for a game server xD.

    Btw, I made a wallpaper changer in the past too. with GUI .
    ~Hermen

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •