Python control of desktop properties

agarbutt at gmail.com agarbutt at gmail.com
Thu Oct 14 16:11:41 EDT 2004


To do this on windows you need to import ctypes (which you may need to
download, http://starship.python.net/crew/theller/ctypes/) and win32con
(which you should have already but if not you can get it from
https://sourceforge.net/projects/pywin32/).  to change th wall paper
use:

from ctypes import *
import win32con

windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, r'<path to
your bitmap>', SPIF_SENDWININICHANGE)

for further reference on SystemParametersInfoA goto:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemparametersinfo.asp

Hope this helps

Andy
Mediocre Person wrote:
> Hello, all.
>
> I'm teaching Python for the first time to some high school students,
and
> it's going well--Tomorrow's lesson: I'm going to show them how to use
a
> list comprehension to simplify a task.
>
> One of my students is interested in using Python to control his
> (Windows) desktop, and wants to write a program to change the desktop

> background or wallpaper. I told him I'd look into this, but I've had
to
> admit defeat.
>
> Can someone point me in the right direction, possibly post the
simplest
> Python program that can accomplish this. I understand this won't be
> portable. At school, we use Win98SE; the student in question is using

> XPHome at home, and I typically use Gentoo Linux/KDE 3.3. If there
were
> a single solution that would address all three environments, I'd
be... 
> well, shocked.
> 
> Merci beaucoup,
> 
> Nick.




More information about the Python-list mailing list