-1
import ctypes
import winsound
SPI_SETDESKWALLPAPER = 20 
while (True):
    x = input("Enter Password. ")
        if x == "blyat":
        print ("motherland russia")
        ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, "D:\\VS Code Project\\COMMUNISM.jpg", 0)
        winsound.PlaySound("USSR Anthem.mp3", winsound.SND_FILENAME)

当我运行程序时,我听不到 .mp3 并且桌面背景变黑而不是更改为我选择的图像(COMMUNISM.jpg)

4

1 回答 1

0

根据您提供的信息,我做了以下工作:

  1. 安装模块“ playsound”并添加它以使用:( pip install playsound)

from playsound import playsound

  1. 使用“ playsound('D:\\...\\Ze\\1.mp3')”代替“ winsound.PlaySound("D:\\...\\Ze\\1.mp3", winsound.SND_FILENAME)

完整代码:

from playsound import playsound  
import ctypes
import winsound
SPI_SETDESKWALLPAPER = 20 
while (True):
    x = input("Enter Password:")
    if x == "blyat":
        print ("motherland russia")
        
        ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, "D:\\...\\Ze\\1.jpg", 0)
      # winsound.PlaySound("D:\\...\\Ze\\1.mp3", winsound.SND_FILENAME)
        playsound('D:\\...\\Ze\\1.mp3')  
        

我在电脑上测试的结果是桌面壁纸换了,播放了mp3。

于 2020-11-04T07:07:02.053 回答