Jump to content

Recommended Posts

Posted

hi,

i've found http://www.autoitscript.com/forum/index.php?showtopic=5798

which says:

RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $sFile)
  DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $sFile, "int", 0)

would change the wallpaper, but when i execute my script

_ChangeWallpaper()

Func _ChangeWallpaper() 
    RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', "C:\Dokumente und Einstellungen\phew\Desktop\hello.jpg")
    DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", "C:\Dokumente und Einstellungen\phew\Desktop\hello.jpg", "int", 0)
EndFunc

the desktop background just becomes light-blue but the new wallpaper is not set. (on rightmouse (desktop) -> properties the wallpaper is previewed but finally its not changed on the desktop!)

someone can help? :)

Posted

hi,

i've found http://www.autoitscript.com/forum/index.php?showtopic=5798

which says:

RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $sFile)
  DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $sFile, "int", 0)

would change the wallpaper, but when i execute my script

_ChangeWallpaper()

Func _ChangeWallpaper() 
    RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', "C:\Dokumente und Einstellungen\phew\Desktop\hello.jpg")
    DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", "C:\Dokumente und Einstellungen\phew\Desktop\hello.jpg", "int", 0)
EndFunc

the desktop background just becomes light-blue but the new wallpaper is not set. (on rightmouse (desktop) -> properties the wallpaper is previewed but finally its not changed on the desktop!)

someone can help? :)

only *.bmp files

Posted

thank you very much :]

my bad, didn't read the other topic carefully

but is there any possibility to use .JPG files, too?

Posted

All together it looks like this:

Func _ChangeDesktopBackground($sFile, $iPosition = 3)
    Local $sCLSID, $tBuffer, $hImage, $sTemp

; Convert image to BMP image
    _GDIP_Startup()
    $hImage = _GDIP_Image($sFile)
    $sCLSID = _GDIP_EncodersGetCLSID('BMP')
    $sTemp  = _Str_ChangeFileExt($sFile, '.bmp')
    _GDIP_ImageSaveToFile($hImage, $sTemp)
    _GDIP_ImageDispose($hImage)
    _GDIP_Shutdown()

; Set wallpaper position
    Switch $iPosition
        Case 1; Tiled
            RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper' , 'reg_sz', '1')
            RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '0')
        Case 2; Centered
            RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper' , 'reg_sz', '0')
            RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '0')
        Case 3; Stretched
            RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper' , 'reg_sz', '0')
            RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '2')
    EndSwitch

; Set wallpaper
    $tBuffer = DllStructCreate("char Text[" & StringLen($sTemp) + 1 & "]")
    DllStructSetData($tBuffer, "Text", $sTemp)
    _API_SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, DllStructGetPtr($tBuffer), BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))
EndFunc
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
  • 3 months 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
×
×
  • Create New...