Reputation: 1429
I was wondering if there was any way to - in Python - change the desktop background of a Windows 7 machine quickly. Right now I'm using:
ctypes.windll.user32.SystemParametersInfoA(20, 0, picture_path, 0)
And while this works, it's not very fast. I was wondering if there was some way to get the background to update in less than a second.
Thanks!
Edit -- It's probably worth noting that my goal it to change the background very fast between many known images.
Upvotes: 2
Views: 1752
Reputation: 8824
If you know how to work with PowerShell, you could try making a PowerShell function to change the background image (http://social.technet.microsoft.com/Forums/en-US/w7itproui/thread/72a9b4bf-071b-47cd-877d-0c0629a9eb90):
Function Set-WallPaper($Value)
{
Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $value
rundll32.exe user32.dll, UpdatePerUserSystemParameters
}
and then call the PowerShell function from python:
import subprocess
subprocess.Popen([r'path/to/PowerShell/script.exe',
'-ExecutionPolicy',
'Unrestricted',
'path/to/background_image.png'], cwd=os.getcwd())
Upvotes: 1
Reputation: 921
Have a look at this. They use bitmaps only but there are functions to convert images like shown here.
Upvotes: 0