相关疑难解决方法(0)

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

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

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

python desktop background

29
推荐指数
7
解决办法
4万
查看次数

在 Python 3 中更改 Windows 10 背景

我一直在寻找通过 python 脚本更改 Windows 10 桌面壁纸的最佳方法。当我尝试运行此脚本时,桌面背景变为纯黑色。

import ctypes

path = 'C:\\Users\\Patrick\\Desktop\\0200200220.jpg'

def changeBG(path):
    SPI_SETDESKWALLPAPER = 20
    ctypes.windll.user32.SystemParametersInfoA(20, 0, path, 3)
    return;

changeBG(path)
Run Code Online (Sandbox Code Playgroud)

我能做些什么来解决这个问题?我正在使用 python3

python windows ctypes python-3.x windows-10

6
推荐指数
1
解决办法
3470
查看次数

如何在Python中设置桌面背景?(视窗)

这就是我正在尝试的:

import ctypes
import os
drive = "F:\\"
folder = "Keith's Stuff"
image = "midi turmes.png"
image_path = os.path.join(drive, folder, image)
SPI_SETDESKWALLPAPER = 20 
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, image_path, 3)
Run Code Online (Sandbox Code Playgroud)

基本上,这段代码显然应该将桌面背景设置为 midi turmes.png,它改变了桌面,但是,由于某些奇怪的原因,它始终是绿色背景(我在 Windows 中的个性化设置是图像后面的绿色背景)如何我要解决这个问题并使桌面看起来像这样吗?:https://i.stack.imgur.com/MRJ1H.png

python ctypes

2
推荐指数
1
解决办法
3269
查看次数

标签 统计

python ×3

ctypes ×2

background ×1

desktop ×1

python-3.x ×1

windows ×1

windows-10 ×1