Jump to content

Change Desktop WallPaper


flyingboz
 Share

Recommended Posts

Func _ChangeDestopWallpaper($bmp, $style = 0)
;===============================================================================
;
; Function Name:    _ChangeDesktopWallPaper
; Description:     Update WallPaper Settings
;Usage:           _ChangeDesktopWallPaper(@WindowsDir & '\' & 'zapotec.bmp',1)
; Parameter(s):  $bmp - Full Path to BitMap File (*.bmp)
;                             [$style] - 0 = Centered, 1 = Tiled, 2 = Stretched
; Requirement(s):   None.
; Return Value(s):  On Success - Returns 0
;                  On Failure -   -1  
; Author(s):        FlyingBoz
;Thanks:        Larry - DllCall Example - Tested and Working under XPHome and W2K Pro
;                    Excalibur - Reawakening my interest in Getting This done.
;
;===============================================================================
      
   If Not FileExists($bmp) Then Return -1
  ;The $SPI*  values could be defined elsewhere via #include - if you conflict,
  ; remove these, or add if Not IsDeclared "SPI_SETDESKWALLPAPER" Logic
   Local $SPI_SETDESKWALLPAPER = 20
   Local $SPIF_UPDATEINIFILE = 1
   Local $SPIF_SENDCHANGE = 2
   Local $REG_DESKTOP= "HKEY_CURRENT_USER\Control Panel\Desktop"
   if $style = 1 then 
   RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 1)
   RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 0)
Else
   RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0)
   RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", $style)
EndIf

   
   DllCall("user32.dll", "int", "SystemParametersInfo", _
         "int", $SPI_SETDESKWALLPAPER, _
         "int", 0, _
         "str", $bmp, _
         "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))
   Return 0
EndFunc  ;==>_ChangeDestopWallpaper

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

i have also done this a long time ago.

http://www.autoitscript.com/forum/index.ph...topic=13426&hl=

and so did ezzetabi

http://www.autoitscript.com/forum/index.php?showtopic=5769

Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

@Wouter

No offense, but your example doesn't support styles

Ezz's example doesn't support optional style, and did not work in my w2k environment.

@ALL

If anyone tries this on a different OS and gets unexpected results, please let me know.

Edited by flyingboz

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

  • 3 months later...
  • 2 years later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...