Simple Image Slideshow v1.0 2011-04-30 Beta

  • Hier ein recht simples Skript zum Darstellen von Bildern als Slideshow mit nur einem Überblendeffekt!

    Spoiler anzeigen
    [autoit]


    #AutoIt3Wrapper_UseX64=n
    #AutoIt3Wrapper_Res_Description=Simple Image Slideshow Program
    #AutoIt3Wrapper_Res_Fileversion=1.0.0.0
    #AutoIt3Wrapper_Res_LegalCopyright=UEZ 2010
    #AutoIt3Wrapper_Res_Language=1033
    #AutoIt3Wrapper_Res_Field=Coded by|UEZ
    #AutoIt3Wrapper_Res_Field=Build|2011-04-30 Beta
    #AutoIt3Wrapper_Res_Field=Compile date|%longdate% %time%
    #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer%
    #AutoIt3Wrapper_UseUpx=y
    #AutoIt3Wrapper_UPX_Parameters=--ultra-brute
    #AutoIt3Wrapper_Run_Obfuscator=y
    #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
    #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3"
    ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

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

    #include <Array.au3>
    #include <File.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

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

    Opt("GUIOnEventMode", 1)
    Opt("MustDeclareVars", 1)

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

    Global $c, $i, $k, $l, $chk, $end, $fn
    Global $hGUI[3], $graphic0, $graphic1, $graphic2, $hGraphic[2], $hImage, $hBrush1, $hBrush2, $hFamily, $hFont, $hFormat, $tLayout, $aInfo
    Global Const $SC_DRAGMOVE = 0xF012, $fsize = 8, $fh = 15
    Global Const $ratio = 16 / 10
    Global Const $height = Floor(@DesktopHeight * 0.9 / 8) * 8, $width = Floor($height * $ratio / 8) * 8
    Global Const $bg_color = "F0F0F0"
    Global Const $title = "Simple Image Slideshow by UEZ"
    Global $imagedir = FileSelectFolder("Select folder with images", "", 4, @ScriptDir)
    If $imagedir = "" Then Exit MsgBox(16, "Error", "No folder selected!", 5)

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

    Global $aFiles = _FileListToArray($imagedir, "*.*", 1)
    If Not UBound($aFiles) Then Exit MsgBox(16, "Error", "No files found!", 5)

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

    $l = 1
    Do
    $chk = StringRegExp($aFiles[$l], "(?i:.*\.jpg|.*\.png|.*\.bmp|.*\.gif)", 3)
    If @error Then
    _ArrayDelete($aFiles, $l)
    $l -= 1
    EndIf
    $l += 1
    Until $l = UBound($aFiles)

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

    If UBound($aFiles) = 1 Then Exit MsgBox(16, "Error", "No images found!", 5)

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

    Global $audio = _FileListToArray(@ScriptDir, "*.mp3", 1)
    Global $play = False, $rand, $a
    $a = UBound($audio) - 1
    If Not @error Then
    If $a Then
    $rand = 1
    Else
    $rand = Random(1, $a, 1)
    EndIf
    $play = True
    SoundPlay($audio[$rand])
    EndIf

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

    Fader_Init($width, $height)

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

    GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $hGUI[2])
    WinActivate($hGUI[2])

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

    GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")

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

    For $k = 1 To UBound($aFiles) - 1
    Fader($imagedir & "\" & $aFiles[$k])
    Next

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

    Sleep(3000)
    _Exit(True)

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

    Func WM_ERASEBKGND($hWnd, $msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($hGUI[2], 0, 0, 0)
    Return 1
    EndFunc

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

    Func Fader($image, $delay = 12, $speed = 3, $sleep = 1500, $display_fn = True)
    Local $a, $d = Mod($c, 2), $iW, $iH, $f, $w, $h
    $hImage = _GDIPlus_ImageLoadFromFile($image)
    $iW = _GDIPlus_ImageGetWidth($hImage)
    $iH = _GDIPlus_ImageGetHeight($hImage)

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

    If $iW < $width + 1 And $iH < $height + 1 Then
    _GDIPlus_GraphicsDrawImageRect($hGraphic[$d], $hImage, $width / 2 - $iW / 2, $height / 2 - $iH / 2, $iW, $iH)
    Else
    If $iW > $iH Then
    $f = $iW / $width
    Else
    $f = $iH / $height
    EndIf
    $w = Int($iW / $f)
    $h = Int($iH / $f)
    _GDIPlus_GraphicsDrawImageRect($hGraphic[$d], $hImage, $width / 2 - $w / 2, $height / 2 - $h / 2, $w, $h)
    EndIf
    If $display_fn Then
    _GDIPlus_GraphicsFillRect($hGraphic[$d], 0, $height - $fh, $width, $fh, $hBrush2)
    $fn = $k & "/" & UBound($aFiles) - 1 & ": " & $image & " (" & $iW & "x" & $iH & ")"
    If StringLen($fn) > Floor($width / 5.5) Then $fn = StringLeft($fn, 30) & "..." & StringRight($fn, StringLen($fn) - StringInStr($fn, "\", 0, -1) + 30)
    _GDIPlus_GraphicsDrawStringEx($hGraphic[$d], $fn, $hFont, $tLayout, $hFormat, $hBrush1)
    EndIf
    For $a = 0 To 0xFF - $speed Step $speed
    WinSetTrans($hGUI[$d], "", $a)
    WinSetTrans($hGUI[Not $d], "", 0xFF - $speed - $a)
    Sleep($delay)
    Next
    _GDIPlus_GraphicsClear($hGraphic[Not $d], "0xFF" & $bg_color)
    $c += 1
    Sleep($sleep)
    EndFunc ;==>Fader

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

    Func Fader_Init($width, $height)
    $hGUI[2] = GUICreate($title, $width, $height, -1, -1, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_DLGMODALFRAME)
    $hGUI[0] = GUICreate($title, $width, $height, 0, 0, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_MDICHILD, $hGUI[2])
    $hGUI[1] = GUICreate($title, $width, $height, 0, 0, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_MDICHILD, $hGUI[2])
    GUISetBkColor("0x" & $bg_color, $hGUI[2])
    GUISetState(@SW_SHOW, $hGUI[2])
    GUISetState(@SW_SHOW, $hGUI[0])
    GUISetState(@SW_SHOW, $hGUI[1])
    WinSetTrans($hGUI[0], "", 0x00)
    WinSetTrans($hGUI[1], "", 0x00)
    _GDIPlus_Startup()
    $hGraphic[0] = _GDIPlus_GraphicsCreateFromHWND($hGUI[0])
    $hGraphic[1] = _GDIPlus_GraphicsCreateFromHWND($hGUI[1])
    _GDIPlus_GraphicsClear($hGraphic[0], "0xFF" & $bg_color)
    _GDIPlus_GraphicsClear($hGraphic[1], "0xFF" & $bg_color)
    $hBrush1 = _GDIPlus_BrushCreateSolid(0xFFF0F080)
    $hBrush2 = _GDIPlus_LineBrushCreate(0, 0, $width, $fh, 0xD0101020, 0x08D0D080, 0x03)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, $fsize)
    $tLayout = _GDIPlus_RectFCreate(0, $height - $fh, 0, 0)
    EndFunc ;==>Fader_Init

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

    Func _Exit($end = False)
    GUIRegisterMsg($WM_LBUTTONDOWN, "")
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush1)
    _GDIPlus_BrushDispose($hBrush2)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphic[0])
    _GDIPlus_GraphicsDispose($hGraphic[1])
    GUIDelete($hGUI[0])
    GUIDelete($hGUI[1])
    GUIDelete($hGUI[2])
    _GDIPlus_Shutdown()
    If $play Then SoundPlay("")
    If $end Then Exit MsgBox(0, "Information", "End reached! Closing in 10 seconds!", 10)
    Exit
    EndFunc ;==>_Exit

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

    Func _GDIPlus_LineBrushCreate($nX1, $nY1, $nX2, $nY2, $iARGBClr1, $iARGBClr2, $iWrapMode = 0)
    Local $tPointF1, $pPointF1
    Local $tPointF2, $pPointF2
    Local $aResult
    $tPointF1 = DllStructCreate("float;float")
    $pPointF1 = DllStructGetPtr($tPointF1)
    $tPointF2 = DllStructCreate("float;float")
    $pPointF2 = DllStructGetPtr($tPointF2)
    DllStructSetData($tPointF1, 1, $nX1)
    DllStructSetData($tPointF1, 2, $nY1)
    DllStructSetData($tPointF2, 1, $nX2)
    DllStructSetData($tPointF2, 2, $nY2)
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateLineBrush", "ptr", $pPointF1, "ptr", $pPointF2, "uint", $iARGBClr1, "uint", $iARGBClr2, "int", $iWrapMode, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[6]
    EndFunc ;==>_GDIPlus_LineBrushCreate

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

    Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($hGUI[2], $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    EndFunc ;==>_WM_LBUTTONDOWN

    [/autoit]

    Läuft sauber nur auf Vista+ Betriebssystemen!!! Sollte jetzt auch unter WinXP funzen!


    Gruß,
    UEZ