Jump to content
Sign in to follow this  
Draygoes

Changeing desktop wallpaper in an app

Recommended Posts

Draygoes

Does anybody know a simple code to change the desktop wallpaper? If so, please post it here.

thx


Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites
BrettF

_ChangeWallpaper made by DaProgramer

You will need Au3Lib for this to work.

#Include <A3LGDIPlus.au3>

Func _ChangeWallpaper($currentfile)
    RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '0')
    RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '2')
   
    $x = 0
    While $x = 0
    $CurrentFile = RotateFiles()
    If StringRight($CurrentFile,3) = "jpg" Or StringRight($CurrentFile,3) = "bmp" Then $x = 1
    WEnd
   
    If StringRight($CurrentFile,3) = "jpg" Then
        _GDIP_StartUp()
        $hImage = _GDIP_ImageLoadFromFile($CurrentFile)
        $sCLSID = _GDIP_EncodersGetCLSID("BMP")
        _GDIP_ImageSaveToFileEx($hImage, @TempDir & "\999.bmp", $sCLSID)
        _GDIP_ShutDown()       
        $CurrentFile = @TempDir & "\999.bmp"
    EndIf
;~ Sleep(500)
    RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $CurrentFile)
    DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $CurrentFile, "int", 0)
EndFunc ;==>_ChangeWallpaper

EDIT: Also have a look at Wallpaper Rotater by Piano_Man

Edited by Bert

Share this post


Link to post
Share on other sites
Draygoes

Cool!!! Thx man!!! :)

One problem. When I use it, I get this error:

---------------------------
AutoIt Error
---------------------------
Line 41  (File "C:\Users\Draygoes\Desktop\AutoItLib.au3"):

Func _API_MultiByteToWideChar($sText, $iCodePage=0, $iFlags=0)

Error: Duplicate function name.
---------------------------
OK   
---------------------------

Am I using the function wrong?

My code:

#Include <A3LGDIPlus.au3>
#include 'AutoItLib.au3'
_ChangeWallpaper("C:\Users\Draygoes\Desktop\custom wallpapers\Comp-14.jpg")


Func _ChangeWallpaper($currentfile)
    RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '0')
    RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '2')
   
    $x = 0
    While $x = 0
    $CurrentFile = RotateFiles()
    If StringRight($CurrentFile,3) = "jpg" Or StringRight($CurrentFile,3) = "bmp" Then $x = 1
    WEnd
   
    If StringRight($CurrentFile,3) = "jpg" Then
        _GDIP_StartUp()
        $hImage = _GDIP_ImageLoadFromFile($CurrentFile)
        $sCLSID = _GDIP_EncodersGetCLSID("BMP")
        _GDIP_ImageSaveToFileEx($hImage, @TempDir & "\999.bmp", $sCLSID)
        _GDIP_ShutDown()       
        $CurrentFile = @TempDir & "\999.bmp"
    EndIf
;~ Sleep(500)
    RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $CurrentFile)
    DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $CurrentFile, "int", 0)
EndFunc;==>_ChangeWallpaper
Edited by draygoes

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites
BrettF
Draygoes

I get this error:

---------------------------
AutoIt Error
---------------------------
Line 12  (File "C:\Users\Draygoes\Desktop\wallpaper.au3"):

$CurrentFile = RotateFiles()
$CurrentFile = ^ ERROR

Error: Unknown function name.
---------------------------
OK   
---------------------------

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites
BrettF

Oh sorry... Needed to remove a bit, since I directly leeched the function out of one of DaProgramer's programs. :)

#Include <A3LGDIPlus.au3>
_ChangeWallpaper("C:\Users\Draygoes\Desktop\custom wallpapers\Comp-14.jpg")


Func _ChangeWallpaper($currentfile)
    RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '0')
    RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '2')
    If StringRight($CurrentFile,3) = "jpg" Then
        _GDIP_StartUp()
        $hImage = _GDIP_ImageLoadFromFile($CurrentFile)
        $sCLSID = _GDIP_EncodersGetCLSID("BMP")
        _GDIP_ImageSaveToFileEx($hImage, @TempDir & "\999.bmp", $sCLSID)
        _GDIP_ShutDown()      
        $CurrentFile = @TempDir & "\999.bmp"
    EndIf
;~ Sleep(500)
    RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $CurrentFile)
    DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $CurrentFile, "int", 0)
EndFunc;==>_ChangeWallpaper

Share this post


Link to post
Share on other sites
Draygoes

Works now. Thanks! :)


Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites
BrettF
Tripredacus

That seems so unsimple! I use this one too!

; copy files to destination
FileCopy ( "\\server\Install\LOGO's\client\MEGA95.BMP" , "C:\Windows" )
; set background image
RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop","Wallpaper","REG_SZ","C:\Windows\MEGA95.BMP")

Of course this is from an app that installs fonts, changes the screensaver, and changes the windows theme as well.

Share this post


Link to post
Share on other sites
BrettF

That seems so unsimple! I use this one too!

; copy files to destination
 FileCopy ( "\\server\Install\LOGO's\client\MEGA95.BMP" , "C:\Windows" )
; set background image
 RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop","Wallpaper","REG_SZ","C:\Windows\MEGA95.BMP")

Of course this is from an app that installs fonts, changes the screensaver, and changes the windows theme as well.

My version converts .jpg to bitmaps...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.