Hi,
hab mir was zusammen gebastelt (größenteils aus fremden Funktionen).
Beim Starten wechselts einmal das Hintergrundbild (z.b. für Autostart) und bei drücken von Strg+Y wechselts ihn ebenfalls (das Windows-eigene Random nervt ).
Im Scriptordner einen Ordner "wallpapers" anlegen und dort alle Bilder einfügen, die man möchte:
#include <file.au3>
HotKeySet("^y", "dochange")
HotKeySet("", "rand")
Global $img_size, $sz, $rnd, $rand = 0
dochange()
While 1
Sleep(100)
WEnd
Func dochange()
Local $path = @ScriptDir & "\wallpapers"
Global $ary = _FileListToArray($path)
Global $oldrnd = IniRead(@ScriptDir & "\wallpapers.ini", "wp", "oldnum", "")
donum()
$img_size = _GetJpegSize($path & "" & $ary[$rnd])
If $img_size[0] < 1600 Or $img_size[1] < 1000 Then
$sz = 2
Else
$sz = 3
EndIf
_ChangeWallpaper($path & "" & $ary[$rnd], $sz)
EndFunc ;==>dochange
Func donum()
$rnd = $oldrnd + 1
If $rnd = $ary[0] + 1 Then $rnd = 1
IniWrite(@ScriptDir & "\wallpapers.ini", "wp", "oldnum", $rnd)
EndFunc ;==>donum
Func _ChangeWallpaper($sFile, $iType) ; Changes the wallpaper to $sFile using $iType as:
Switch $iType
;1 Tiled
Case 1
RegWrite('HKEY_CURRENT_USER\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '1')
RegWrite('HKEY_CURRENT_USER\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '0')
;2 Centered
Case 2
RegWrite('HKEY_CURRENT_USER\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '0')
RegWrite('HKEY_CURRENT_USER\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '0')
;3 Stretched
Case 3
RegWrite('HKEY_CURRENT_USER\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '0')
RegWrite('HKEY_CURRENT_USER\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '2')
EndSwitch
RegWrite('HKEY_CURRENT_USER\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $sFile)
DllCall("User32.dll", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $sFile, "int", 0)
Return 0
EndFunc ;==>_ChangeWallpaper
Func _GetJpegSize($file)
Local $size[2]
Local $fs, $pos = 3
If Not _FileReadAtOffsetHEX($file, 1, 2) = "FFD8" Then
SetError(1); Not Jpeg
Return ""
EndIf
$fs = FileGetSize($file)
While $pos < $fs
$data = _FileReadAtOffsetHEX($file, $pos, 4)
If StringLeft($data, 2) = "FF" Then; Valid segment start
If StringInStr("C0 C2 CA C1 C3 C5 C6 C7 C9 CB CD CE CF", StringMid($data, 3, 2)) Then; Segment with size data
$seg = _FileReadAtOffsetHEX($file, $pos + 5, 4)
$size[1] = Dec(StringLeft($seg, 4))
$size[0] = Dec(StringRight($seg, 4))
Return ($size)
Else
$pos += Dec(StringRight($data, 4)) + 2
EndIf
Else
ExitLoop
EndIf
WEnd
SetError(2); Segment not found
Return ("")
EndFunc ;==>_GetJpegSize
Func _FileReadAtOffsetHEX($file, $offset, $bytes)
Local $tfile = FileOpen($file, 0)
Local $tstr = ""
FileRead($tfile, $offset - 1)
For $i = $offset To $offset + $bytes - 1
$tstr &= Hex(Asc(FileRead($tfile, 1)), 2)
Next
FileClose($tfile)
Return ($tstr)
EndFunc ;==>_FileReadAtOffsetHEX
Viel Spass damit,
x0r