Sign in to follow this  
Followers 0
ludocus

_setwallpaper (built in bmp converter)

4 posts in this topic

#1 ·  Posted (edited)

here\'s the function:

I saved it in my include list as desktop.au3

#Include <GDIPlus.au3>


;===============================================================================
;
; Description:         Sets the desktop wallpaper picture
; Syntax:              _setwallpaper($pic, $style = 0, $warn = 1)
; Parameter(s):     $pic      - Path and filename of the picture to set ( JPG or BITMAP )
;                           $style    - 0 = centered   1 = Tiled   2 = Stretched    ( set to 0 )
;                          $warn     - 0 = false     1 = true                      ( set to 1 )
; Requirement(s):   none
; Return Value(s):  On Success - Returns 0
;                           On Failure - Returns -1
; Author(s):           ludocus
; Note(s):              $warn may be anoying,.. Build in picture converter to bmp
;
;===============================================================================
Func _setwallpaper($pic, $style = 0, $warn = 1)
    if $warn = 1 then
    $m1 = @DesktopHeight/2
    $m2 = @DeskTopWidth/2
   ToolTip (\"Setting new walpaper\", $m2, $m1, \"Please wait..\", 1  )
   EndIf
   If Not FileExists($pic) Then Return -1
   
   $s = StringSplit ( $pic, \'.\', 1 )
if $s[2] = \'bmp\' Then   ;If Not $s[2] = \'bmp\' then.... didn\'t seem to be working, so that\'s why I did this..
    $bmp = \'true\'
Else
    $bmp = \'false\'
EndIf


If $bmp = \'false\' then
$text = StringReplace($pic, \".jpg\", \".bmp\")
_GDIPlus_Startup ()
$hImage = _GDIPlus_ImageLoadFromFile($pic)
$sCLSID = _GDIPlus_EncodersGetCLSID (\"BMP\")
_GDIPlus_ImageSaveToFileEx($hImage, $text, $sCLSID)
_GDIPlus_ShutDown()
$pic = $text
EndIf
   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\", $pic, _
         \"int\", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))
   Return 0
   if $warn = 1 then
   sleep ( 2000 )
   EndIf
EndFunc ;==>_setwallpaper

Have Fun!

Created by: flyingboz

edited by: ludocus

Edited by ludocus

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

I bet you didnt wrote that by yourself.

in english you would say: I bet you didn't write that by yourself. Edited by ludocus

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  
Followers 0