效果如图

edit.ps1

$regkey = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" 

$name = "AppsUseLightTheme" 

$exists = Get-ItemProperty -Path "$regkey" -Name "$name" -ErrorAction SilentlyContinue 

If (($exists -ne $null) -and ($exists.Length -ne 0)) {    

Remove-ItemProperty -Path $regkey -Name $name 
./a.exe
}else{    

New-ItemProperty -Path $regkey -Name $name -Value 0
./b.exe
}

a.py(b.py就不写了,直接放另一张图片的路径就好了)

import win32api
import win32gui
import win32con
import os
import sys

def setWallPaper(pic):
    # open register
    regKey = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, win32con.KEY_SET_VALUE)
    win32api.RegSetValueEx(regKey, "WallpaperStyle", 0, win32con.REG_SZ, "10")
    win32api.RegSetValueEx(regKey, "TileWallpaper", 0, win32con.REG_SZ, "0")
    # refresh screen
    win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER, pic, win32con.SPIF_SENDWININICHANGE)


setWallPaper(os.getcwd()+'\\1.jpg')


Last modification:February 10, 2020
如果觉得我的文章对你有用,请随意赞赏