如何使用Python 2.7.3更改Windows背景 [英] How to Change Windows background using Python 2.7.3
问题描述
我正在使用Windows 8(尚未更新至8.1)
I am using windows 8 (not yet updated to 8.1)
我正在使用的代码为
导入ctypes
import ctypes
SPI_SETDESKWALLPAPER = 20
SPI_SETDESKWALLPAPER = 20
ctypes.windll.user32.SystemParametersInfoA (SPI_SETDESKWALLPAPER,0, word.jpg,0)
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, "word.jpg", 0)
打印 hi
出于某种原因,无论我是否给它一个有效的图像(与程序位于同一目录中),无论图像类型(bmp,gif,jpg)如何,代码总是最终将背景设置为黑色屏幕。
For some reason regardless if i give it a valid image (in the same directory as program) or not, regardless of type of image (bmp, gif, jpg) the code always ends up setting my background to a black screen.
为什么?如何解决?
推荐答案
尝试通过 SPIF_SENDCHANGE
(即 2 )作为最后一个参数。您可能还需要按位-或使用 SPIF_UPDATEINIFILE
(它是 1 )。
Try passing SPIF_SENDCHANGE
(which is 2) as the last parameter. You might also need to bitwise-or it with SPIF_UPDATEINIFILE
(which is 1).
这篇关于如何使用Python 2.7.3更改Windows背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!