user32.dll bei XP, Vista, Win7

  • HAllo Community!

    Bin neu hier bei Forum und noch Anfänger bei AutoIT. Ich habe ein Script zusammengebastelt, das Hintergrundsbilder auf dem Desktop wechselt. Sowas ähnliches wie bei Win7, bloß wollte, dass die jenige, die noch Win2000, WinXP oder Vista besitzen auch was davon habn. Das Problem dabei, dass es NUR bei Vista und Win7 dann funktioniert. Ursache habe ich gefunden: user32.dll bei XP besitzt keine nötige Funktionen. Erst ab Version 6.0 dieser Bibliothek wird Programm richtig ausgeführt, sonst erscheint bloß leeres Desktop. Kennt jemand eine Lösung außer user32.dll Ver5 auf Ver6 zu ersetzen?

    Anlagen:
    desktop.zip(keine Viren)

    autoit.de/wcf/attachment/6824/
    Mfg, simi4

  • Registry:
    HKEY_CURRENT_USER\Control Panel\Desktop\
    Hier ist es glaube ich der Eintrag "OriginalWallpaper" oder der Eintrag "Wallpaper",
    ich bin mir aber nicht 100pro sicher!

  • Ich hab' XP Pro,
    HKEY_CURRENT_USER\Control Panel\Desktop\
    Eintrag : "ConvertedWallpaper" , der ist es (hab' ich nachgeprüft, funktioniert)!

  • Allgemein würd ich mal sagen: Stell doch bitte den Quellcode mit rein ;) Ich hab auch schonmal ein bisschen mit ConvertedWallpaper rumprobiert, aber einfach nur ändern und dann Desktop aktualisieren (über .dll-Befehl) bringt nichts, ich vermute mal (auch durch das ConvertedWallpaper ;) ), dass der Hintergrund ein bestimmtes Format haben muss (Höhe-Breite, Dateiformat, ...)

  • Ich hab einige Sachen dort schon ausprobiert(auskommentiert)...
    Großer auskommentierter Block ist für XP-User und niedriger gedacht. Der macht eigentlich Probleme

    Spoiler anzeigen
    [autoit]

    #include <array.au3>
    #include <File.au3>
    #include <GDIPlus.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $SPIF_UPDATEINIFILE = 0x01
    Global Const $SPIF_SENDWININICHANGE = 0x02
    Global Const $SPI_SETSCREENSAVEACTIVE = 0x11
    Global Const $SPI_SETDESKWALLPAPER = 0x14
    Global Const $SPI_GETDESKWALLPAPER = 0x73
    ;Dim $speed0
    $pixdir=FileSelectFolder("Choose a folder with your pictures", "")

    [/autoit] [autoit][/autoit] [autoit]

    $filelist=_FileListToArray($pixdir & "\", "*.jpg")
    ;_ArrayDisplay($filelist, "filelist")
    $pixend=$filelist[0]

    [/autoit] [autoit][/autoit] [autoit]

    $string=_ArrayToString($filelist, ";",1)

    [/autoit] [autoit][/autoit] [autoit]

    $OS=@OSVersion
    ;MsgBox(0,"OS", $OS)
    #cs
    if $OS='WIN_XP' OR $OS='WIN_2000' then ;WIN_2000 oder WIN_00?
    $speed0=InputBox("Speed", "Set speed in seconds", 30)
    ElseIf $speed0<10 or $speed0>86401 Then
    $speed0=InputBox("Speed", "Set speed in area between 10 and 86400 seconds", 30)
    ElseIf Not IsNumber($speed0) Then
    InputBox("Speed", "Please write only numbers!", 30)
    $speed=$speed0 * 1000
    for $i= 1 to $pixend
    $r=Random(1,$pixend,1)
    ;MsgBox(0,"r", $r)
    $jpg=$filelist[$r]
    ;MsgBox(0,"jpg",$jpg)
    Global $Bitmap = $pixdir & "\" & $jpg
    ;MsgBox(0,"bitmap", $Bitmap)

    _GDIPlus_Startup()
    $Bild = _GDIPlus_ImageLoadFromFile($Bitmap)
    _GDIPlus_ImageSaveToFile($Bild, @WindowsDir & "\Wallpaper.bmp")
    _GDIPlus_ImageDispose($Bild)
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    $bild1=@WindowsDir & "\Wallpaper.bmp"
    MsgBox(0,"123",$bild1)
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper", "REG_SZ", "0")
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", "2")
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "ConvertedWallpaper", "REG_SZ", $bild1)
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "OriginalWallpaper", "REG_SZ", @UserProfileDir & "\Lokale Einstellungen\Anwendungsdaten\Microsoft\Wallpaper1.bmp")
    $test=@UserProfileDir & "\Lokale Einstellungen\Anwendungsdaten\Microsoft\Wallpaper1.bmp"
    ;FileCopy("E:\Windows\System32\user32.dll", "C:\windows\system32\user32neu.dll",1)
    ;$test2=DllOpen("user32.dll")
    ;$test1=dllcall("user32.dll","long","SystemParametersInfo")
    ;MsgBox(4096,"123",$test1)
    _SetDeskWallpaper($bild1)
    Sleep($speed)
    If $i=$pixend Then
    $i=1
    Endif
    Next
    EndIf
    #ce
    ;fuer vista und win7(win7 ist immer noch vista, bloss version 6.1)
    If $OS="WIN_VISTA" Then

    $speed0=InputBox("Speed", "Set speed in seconds", 30)
    If $speed0<10 or $speed0>86401 Then
    $speed0=InputBox("Speed", "Set speed in area between 10 and 86400 seconds", 30)
    If Not IsNumber($speed0) Then
    InputBox("Speed", "Please write only numbers!", 30)
    EndIf
    EndIf
    $speed=$speed0 * 1000
    for $i= 1 to $pixend
    $r=Random(1,$pixend,1)
    ;MsgBox(0,"r", $r)
    $jpg=$filelist[$r]
    ;MsgBox(0,"jpg",$jpg)
    Global $Bitmap = $pixdir & "\" & $jpg
    ;MsgBox(0,"bitmap", $Bitmap)
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper", "REG_SZ", "0")
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", "2")
    _SetDeskWallpaper($Bitmap)
    Sleep($speed)
    If $i=$pixend Then
    $i=1
    Endif
    Next
    ;fur winxp und 2000
    ElseIf $OS='WIN_XP' OR $OS='WIN_2000' then ;WIN_2000 oder WIN_00?
    $speed0=InputBox("Speed", "Set speed in seconds", 30)
    ElseIf $speed0<10 or $speed0>86401 Then
    $speed0=InputBox("Speed", "Set speed in area between 10 and 86400 seconds", 30)
    ElseIf Not IsNumber($speed0) Then
    InputBox("Speed", "Please write only numbers!", 30)
    $speed=$speed0 * 1000
    for $i= 1 to $pixend
    $r=Random(1,$pixend,1)
    ;MsgBox(0,"r", $r)
    $jpg=$filelist[$r]
    ;MsgBox(0,"jpg",$jpg)
    Global $Bitmap = $pixdir & "\" & $jpg
    ;MsgBox(0,"bitmap", $Bitmap)

    _GDIPlus_Startup()
    $Bild = _GDIPlus_ImageLoadFromFile($Bitmap)
    _GDIPlus_ImageSaveToFile($Bild, @WindowsDir & "\Wallpaper.bmp")
    _GDIPlus_ImageDispose($Bild)
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    $bild1=@WindowsDir & "\Wallpaper.bmp"
    MsgBox(0,"123",$bild1)
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper", "REG_SZ", "0")
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", "2")
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "ConvertedWallpaper", "REG_SZ", $bild1)
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "OriginalWallpaper", "REG_SZ", @UserProfileDir & "\Lokale Einstellungen\Anwendungsdaten\Microsoft\Wallpaper1.bmp")
    $test=@UserProfileDir & "\Lokale Einstellungen\Anwendungsdaten\Microsoft\Wallpaper1.bmp"
    ;FileCopy("E:\Windows\System32\user32.dll", "C:\windows\system32\user32neu.dll",1)
    ;$test2=DllOpen("user32.dll")
    ;$test1=dllcall("user32.dll","long","SystemParametersInfo")
    ;MsgBox(4096,"123",$test1)
    _SetDeskWallpaper($bild1)
    Sleep($speed)
    If $i=$pixend Then
    $i=1
    Endif
    Next
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Func _SetDeskWallpaper($Bitmap)
    DllCall("user32.dll", "long", "SystemParametersInfo" _
    , "long", $SPI_SETDESKWALLPAPER _
    , "long", 0 _
    , "str", $Bitmap _
    , "long", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDWININICHANGE) _
    )
    EndFunc ;==>_SetDeskWallpaper

    [/autoit] [autoit][/autoit] [autoit]

    #cs
    Else
    Do
    InputBox("Speed", "Please write numbers between 10 and 86400!", 30)
    until $speed0>10 or $speed0<86401

    Func _GetDeskWallpaper()
    Local $Filename = DllStructCreate("char[256]")
    DllCall("user32.dll", "long", "SystemParametersInfo" _
    , "long", $SPI_GETDESKWALLPAPER _
    , "long", 255 _
    , "ptr", DllStructGetPtr($Filename) _
    , "long", 0 _
    )

    Return DllStructGetData($Filename, 1)
    EndFunc ;==>_GetDeskWallpaper

    [/autoit] [autoit][/autoit] [autoit]

    #ce

    [/autoit]

    :)

    2 Mal editiert, zuletzt von simi4 (9. Dezember 2009 um 15:23)

  • Diese Funktion läuft jedenfalls auf XP SP3, für andere Systeme solltest du sie noch testen ;)

    Spoiler anzeigen
    [autoit]

    #include<GDIplus.au3>
    Global Const $WALLPOS_KEEP = -1
    Global Const $WALLPOS_CENTER = 0
    Global Const $WALLPOS_TILE = 1
    Global Const $WALLPOS_STRETCH = 2

    [/autoit] [autoit][/autoit] [autoit]

    Func _SetWallpaper($sWallpaper, $iStyle = $WALLPOS_KEEP)
    ;Author: Prog@ndy
    Local $sRegKey = "HKEY_CURRENT_USER\Control Panel\Desktop"
    $sWallpaper = FileGetLongName($sWallpaper, 1)
    If @error Then Return SetError(1,0,0)
    RegDelete($sRegKey, 'ConvertedWallpaper Last WriteTime')
    Local $sEnding = StringLeft($sWallpaper, 4)
    If (@OSBuild<6000 And $sEnding <> '.bmp') Or ($sEnding<>'.bmp' And $sEnding<>'jpeg' And $sEnding <>'.jpg') Then

    [/autoit] [autoit][/autoit] [autoit]

    ; SHGetFolderPathW by wraithdu
    Local $path = DllStructCreate("wchar[260]")
    Local $aResult = DllCall("shell32.dll", "int", "SHGetFolderPathW", _
    "hwnd", 0, _
    "int", 0x001C, _ ; CSIDL_LOCAL_APPDATA
    "ptr", 0, _
    "dword", 0x0000, _ ; SHGFP_TYPE_CURRENT
    "ptr", DllStructGetPtr($path) _
    )
    If @error Or $aResult[0] < 0 Then Return SetError(2, @error, 0)
    $path = DllStructGetData($path, 1)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Local $hImage = _GDIPlus_ImageLoadFromFile($sWallpaper)
    _GDIPlus_ImageSaveToFile($hImage, $path & '\Microsoft\Wallpaper1.bmp')
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    RegWrite($sRegKey, 'ConvertedWallpaper', $sWallpaper)
    RegWrite($sRegKey, 'OriginalWallpaper', $path & '\Microsoft\Wallpaper1.bmp' )
    RegWrite($sRegKey, 'Wallpaper', $path & '\Microsoft\Wallpaper1.bmp' )
    $sWallpaper = $path & '\Microsoft\Wallpaper1.bmp'
    Else
    RegDelete($sRegKey, 'ConvertedWallpaper')
    RegDelete($sRegKey, 'OriginalWallpaper')
    RegWrite($sRegKey, 'Wallpaper', $sWallpaper)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Switch $iStyle
    Case $WALLPOS_TILE
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper", "REG_SZ", "1")
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", "0")
    Case $WALLPOS_CENTER, $WALLPOS_STRETCH
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper", "REG_SZ", "0")
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", $iStyle)
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Local Const $SPIF_UPDATEINIFILE = 0x01
    Local Const $SPIF_SENDWININICHANGE = 0x02
    Local Const $SPI_SETSCREENSAVEACTIVE = 0x11
    Local Const $SPI_SETDESKWALLPAPER = 0x14
    Local Const $SPI_GETDESKWALLPAPER = 0x73

    [/autoit] [autoit][/autoit] [autoit]

    Local $aResult = DllCall("user32.dll", "int", "SystemParametersInfoW" _
    , "uint", $SPI_SETDESKWALLPAPER _
    , "uint", 0 _
    , "wstr", $sWallpaper _
    , "uint", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDWININICHANGE) _
    )
    If @error Or $aResult[0] = 0 Then Return SetError(3, @error,0)
    Return 1
    EndFunc

    [/autoit]
  • ok probiere daheim.
    mal eine frage

    [autoit]

    Local $aResult = DllCall("shell32.dll", "int", "SHGetFolderPathW", _
    "hwnd", 0, _
    "int", 0x001C, _ ; CSIDL_LOCAL_APPDATA
    "ptr", 0, _
    "dword", 0x0000, _ ; SHGFP_TYPE_CURRENT
    "ptr", DllStructGetPtr($path) _
    )

    [/autoit][autoit][/autoit][autoit][/autoit]

    Wo kann ich diese ganze Parameter kriegen(in Hex und übersetzt)?

    :)