Desktop Background.

BlitzMax Forums/BlitzMax Programming/Desktop Background.

Paul "Taiphoz"(Posted 2011) [#1]
Just wondering if anyone has any example code of how to change the current desktop background with blitz, max or 3d I have both.

Not done much code for years so the simpler the better. thanks in advance.


Kryzon(Posted 2011) [#2]
From Google I noticed the Windows API command to do so is 'SystemParametersInfo'.
So I searched all forums for this name.

http://blitzbasic.com/Community/posts.php?topic=90016
http://blitzbasic.com/Community/posts.php?topic=61383
http://blitzbasic.com/Community/posts.php?topic=80128

EDIT: Never forget to query the user for such action.

Last edited 2011


Paul "Taiphoz"(Posted 2011) [#3]
That helped and gave me exactly what I wanted, thanks m8.


Grey Alien(Posted 2011) [#4]
If you find out how to do it on Mac, please report back!


ImaginaryHuman(Posted 2011) [#5]
OSX maybe with some applescript?:

tell application "Finder"
set desktop picture to POSIX file "/your/filename.jpg"
end tell

You can run it from the command line using osascript, or from Python using something like

import subprocess

SCRIPT = """/usr/bin/osascript<<END
tell application "Finder"
set desktop picture to POSIX file "%s"
end tell
END"""

def set_desktop_background(filename):
subprocess.Popen(SCRIPT%filename, shell=True)


Grey Alien(Posted 2011) [#6]
Very interesting. Can you call such a script from in BMax though? Like via a batch file?


Grey Alien(Posted 2011) [#7]
OK I'm a little close. Need to turn this into a function that can e imported into BMax:

http://stackoverflow.com/questions/3220416/how-to-get-and-set-the-wallpaper-in-objective-c-on-mac-osx