如何使用python更改桌面背景? [英] How can I change my desktop background with python?

查看:356
本文介绍了如何使用python更改桌面背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用python更改桌面背景?

How can I change my desktop background with python?

我想在Windows和Linux上都这样做.

I want to do it in both Windows and Linux.

推荐答案

在具有python2.5或更高版本的Windows上,使用ctypes加载user32.dll并调用

On Windows with python2.5 or higher, use ctypes to load user32.dll and call SystemParametersInfo() with SPI_SETDESKWALLPAPER action.

例如:

import ctypes
SPI_SETDESKWALLPAPER = 20 
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, "image.jpg" , 0)

这篇关于如何使用python更改桌面背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆