Jump to content

Changing desktop background


Recommended Posts

Is there a easy way to do this?

Check out these registry thingos:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\General\Wallpaper

HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper

The top is for any filetype other than BMP....

Link to comment
Share on other sites

I made this a while ago, maybe it will help you:

Don't have function credits :shocked:

CODE
;HKCU/Control Panel/Desktop/Wallaper
#include <GUIConstants.au3>
#include <File.au3>
; =================================================================================================
; Global Constants
; =================================================================================================
Global Const $SPI_SETDESKWALLPAPER = 20
Global Const $SPIF_SENDCHANGE      = 2
Global $Allfiles="",$SearchDir = @WindowsDir&"\Web\Wallpaper\"

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Wallpaper Rotater", 757, 251, 249, 356)
GUISetBkColor(0xD8E4F8)
$Pic1 = GUICtrlCreatePic("", 220, 56, 164, 148, BitOR($SS_NOTIFY,$WS_GROUP,$WS_BORDER), $WS_EX_STATICEDGE)
$Combo1 = GUICtrlCreateCombo("Picture 1", 24, 56, 185, 25)
$Input1 = GUICtrlCreateInput("10", 24, 160, 57, 27, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlSetLimit($Input1, 2)
GUICtrlSetFont(-1, 12, 800, 0, "Rockwell")
$Button1 = GUICtrlCreateButton("Apply", 72, 200, 73, 33, 0)
$Label1 = GUICtrlCreateLabel("Wallpaper Rotater", 71, 8, 236, 38, $SS_CENTER)
GUICtrlSetFont(-1, 22, 800, 0, "ThereSignHead3")
GUICtrlSetColor(-1, 0x800000)
GUICtrlSetBkColor(-1, 0xD8E4F8)
$Combo2 = GUICtrlCreateCombo("Picture 2", 24, 88, 185, 25)
$Combo3 = GUICtrlCreateCombo("Picture 3", 24, 120, 185, 25)
$Pic2 = GUICtrlCreatePic("", 392, 56, 164, 148, BitOR($SS_NOTIFY,$WS_GROUP,$WS_BORDER), $WS_EX_STATICEDGE)
$Pic3 = GUICtrlCreatePic("", 565, 56, 164, 148, BitOR($SS_NOTIFY,$WS_GROUP,$WS_BORDER), $WS_EX_STATICEDGE)
GUICtrlCreateLabel("Integer Delay", 88, 160, 102, 26)
GUICtrlSetFont(-1, 12, 800, 0, "Trebuchet MS")
GUICtrlSetBkColor(-1, 0xD8E4F8)
GUICtrlCreateLabel("1", 289, 210, 13, 26)
GUICtrlSetFont(-1, 12, 800, 0, "Trebuchet MS")
GUICtrlSetBkColor(-1, 0xD8E4F8)
GUICtrlCreateLabel("2", 463, 210, 13, 26)
GUICtrlSetFont(-1, 12, 800, 0, "Trebuchet MS")
GUICtrlSetBkColor(-1, 0xD8E4F8)
GUICtrlCreateLabel("3", 644, 210, 13, 26)
GUICtrlSetFont(-1, 12, 800, 0, "Trebuchet MS")
GUICtrlSetBkColor(-1, 0xD8E4F8)
$Label2 = GUICtrlCreateLabel("Created By Paulie", 447, 8, 230, 38, $SS_CENTER)
GUICtrlSetFont(-1, 22, 800, 0, "ThereSignHead3")
GUICtrlSetColor(-1, 0x800000)
GUICtrlSetBkColor(-1, 0xD8E4F8)
$Files = _FileListToArray($SearchDir, "*.bmp",1)
For $int = 1 to $Files[0]
    $AllFiles = $AllFiles&"|"&$Files[$int]
Next
GUICtrlSetData($Combo1, $AllFiles)
GUICtrlSetData($Combo2, $AllFiles)
GUICtrlSetData($Combo3, $AllFiles)
$info1 = GUICtrlRead($Combo1)
$info2 = GUICtrlRead($Combo2)
$info3 = GUICtrlRead($Combo3)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()

    $img1 = GUICtrlRead($Combo1)
        If $img1 <> $Info1 then 
            GUICtrlSetImage($Pic1, $SearchDir&$img1)
            $Info1 = $img1
        Endif
    $img2 = GUICtrlRead($Combo2)
        If $img2 <> $Info2 then 
            GUICtrlSetImage($Pic2, $SearchDir&$img2)
            $Info2 = $img2
        EndIf
    $img3 = GUICtrlRead($Combo3)
        If $img3 <> $Info3 then 
            GUICtrlSetImage($Pic3, $SearchDir&$img3)
            $Info3 = $img3
        Endif
    
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetState($Form1, @SW_HIDE)
            Accept($SearchDir&$img1, $SearchDir&$img2, $SearchDir&$img3, GUICtrlRead($Input1))
    EndSwitch
WEnd

Func Accept($i_image1, $i_image2, $i_image3, $s_delay)

While 1
    $msg2 = GUIGetMsg()
If $msg2 = $GUI_EVENT_CLOSE Then Exit

    _SetDesktopWallpaper($i_image1, True)
    Sleep($s_delay*1000)
    _SetDesktopWallpaper($i_image2, True)
    Sleep($s_delay*1000)
    _SetDesktopWallpaper($i_image3, True)
    Sleep($s_delay*1000)
WEnd
EndFunc

; =================================================================================================
; Description ..: Sets the desktop wallpaper to the BMP file passed in.
; Parameters ...: $sBMPFile     - Full path to the BMP file
;                 $bUpdate      - Specifies whether the user profile is to be updated. If True, the
;                   WM_SETTINGCHANGE message is broadcast to all top level windows to  notify  them
;                   of change.
; Return values : True
;                 False
; =================================================================================================
Func _SetDesktopWallpaper($sBMPFile, $bUpdate=True)
  Local $aResult
  Local $iWinIni = 0

  if $bUpdate then $iWinIni = $SPIF_SENDCHANGE
  $aResult = DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_SETDESKWALLPAPER, _
                     "int", 0, "str", $sBMPFile, "int", $iWinIni)
  Return $aResult[0] <> 0
EndFunc
Edited by Paulie
Link to comment
Share on other sites

Check out these registry thingos:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\General\Wallpaper

HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper

The top is for any filetype other than BMP....

I tried changing these values but no immediate changed happened. However, when I rightclicked and went to properties the image I had written to the registry was the default even though it wasn't the current background. Is there any way that you know that would enable you to set it immediately?

@Paulie

Thanks, that works great for bitmaps... Could that be used for jpegs in anyway?

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Here's a function I made for applying images that aren't bmps. It uses PictView command-line converter

;  _applyimage(path_to_image, style, tile)
;  style 1, tile 1 = tiled
;  style 2, tile 0 = stretched
;  style 1, tile 0 = centered

Func applyimage($path, $style, $tile)
    $apply_type = StringRight($path, 4)
    If $apply_type = ".jpg" Or _
            $apply_type = ".gif" Or _
            $apply_type = ".png" Then
        FileDelete(@WindowsDir & "\xwall.bmp")
        RunWait(@ScriptDir & "\pvw32con.exe " & '"' & $path & '"' & " -w --oo " & '"' & @WindowsDir & "\xwall.bmp" & '"', _
                @ScriptDir, @SW_HIDE)
    Else
        FileCopy($path, @WindowsDir & "\xwall.bmp", 1)
    EndIf
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", $style)
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper", "REG_SZ", $tile)
    Sleep(250)
    DllCall("User32.dll", "int", "SystemParametersInfo", _
            "int", 20, _
            "int", 0, _
            "string", @WindowsDir & "\xwall.bmp", _
            "int", 0x01)
EndFunc
Edited by xcal
Link to comment
Share on other sites

Here's a function I made for applying images that aren't bmps. It uses PictView command-line converter

;  _applyimage(path_to_image, style, tile)
;  style 1, tile 1 = tiled
;  style 2, tile 0 = stretched
;  style 1, tile 0 = centered

Func applyimage($path, $style, $tile)
    $apply_type = StringRight($path, 4)
    If $apply_type = ".jpg" Or _
            $apply_type = ".gif" Or _
            $apply_type = ".png" Then
        FileDelete(@WindowsDir & "\xwall.bmp")
        RunWait(@ScriptDir & "\pvw32con.exe " & '"' & $path & '"' & " -w --oo " & '"' & @WindowsDir & "\xwall.bmp" & '"', _
                @ScriptDir, @SW_HIDE)
    Else
        FileCopy($path, @WindowsDir & "\xwall.bmp", 1)
    EndIf
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", $style)
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper", "REG_SZ", $tile)
    Sleep(250)
    DllCall("User32.dll", "int", "SystemParametersInfo", _
            "int", 20, _
            "int", 0, _
            "string", @WindowsDir & "\xwall.bmp", _
            "int", 0x01)
EndFunc
Ugh.. fortunately that works. Unfortunately having to do it with an external .exe is very cumbersome...
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Ugh.. fortunately that works. Unfortunately having to do it with an external .exe is very cumbersome...

i know i've seen some around here.. i havent tried any (im happy with my wallpaper :shocked: )

http://www.autoitscript.com/forum/index.ph...te=%2Bwallpaper

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

i know i've seen some around here.. i havent tried any (im happy with my wallpaper :shocked: )

http://www.autoitscript.com/forum/index.ph...te=%2Bwallpaper

Every single one of these that I tried either uses bitmaps or converts the image to a bitmap (with an external program) before applying it to the desktop... I think someone (in one of those topics) said that they fixed that with vista so that would be great!
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
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
 Share

  • Recently Browsing   0 members

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