System Independent Wallpaper Changer

  • Thread starter Terrance N. Phillip
  • Start date
T

Terrance N. Phillip

This is what I've got... the code should work on a typical Windows
system, I think...
============================================
import os
import random
import time

# I'm not sure what to expect for Win98, WinME, etc. I've
# only tried it with xp...
if os.name in ['nt', 'win98', 'me']:
osWindows = True
import ctypes
import win32con
import Image
pth = 'c:/path/to/wallpapers'
else:
osWindows = False
pth = '~/path/to/wallpapers'

picfiles = os.listdir(pth)

while True:
jpg = random.choice(picfiles)
if os_type = 'W':
bmp = 'c:/wallpaper.bmp'
Image.open(pth+jpg).save(bmp)
cs = ctypes.c_buffer(bmp)
ok =
ctypes.windll.user32.SystemParametersInfoA(win32con.SPI_SETDESKWALLPAPER,0,cs,0)
else:
pass
' set kde wallpaper to jpg <------------- *** ---
time.sleep(60)
=================================================

I've done some searching, and can't seem to find a programatic way of
getting *** that to happen.

Thanks for any advice.

Nick.
 
P

Peter Hansen

Terrance said:
This is what I've got... the code should work on a typical Windows
system, I think...
if os.name in ['nt', 'win98', 'me']:
osWindows = True
else:
osWindows = False [snip]
if os_type = 'W':

I think you might have a problem with the above, where it seems you
changed from one approach to another part way through solving the
problem... should throw a NameError pretty quick when you run it though.

-Peter
 
C

Chris Lambacher

you probably want
if sys.platform == 'win32':

instead of
if os.name in ['nt', 'win98', 'me']:

-Chris
This is what I've got... the code should work on a typical Windows
system, I think...
============================================
import os
import random
import time

# I'm not sure what to expect for Win98, WinME, etc. I've
# only tried it with xp...
if os.name in ['nt', 'win98', 'me']:
osWindows = True
import ctypes
import win32con
import Image
pth = 'c:/path/to/wallpapers'
else:
osWindows = False
pth = '~/path/to/wallpapers'

picfiles = os.listdir(pth)

while True:
jpg = random.choice(picfiles)
if os_type = 'W':
bmp = 'c:/wallpaper.bmp'
Image.open(pth+jpg).save(bmp)
cs = ctypes.c_buffer(bmp)
ok =
ctypes.windll.user32.SystemParametersInfoA(win32con.SPI_SETDESKWALLPAPER,0,cs,0)
else:
pass
' set kde wallpaper to jpg <------------- *** ---
time.sleep(60)
=================================================

I've done some searching, and can't seem to find a programatic way of
getting *** that to happen.

Thanks for any advice.

Nick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top