Jump to content

Animator


Recommended Posts

I'm not sure how else to describe it. You can load a folder and sort the images, add audio, change frames per second, and go into full screen. The key combination for full screen is Alt+Enter. I suppose it would also work as a slide show program :whistle:

Suggestions/comments appreciated!

#include <GUIConstants.au3>
#include <Array.au3>
#include <Misc.au3>
#include <Sound.au3>

HotKeySet("!{ENTER}", "fullscreen")

Func Declarations ()
    Global $pics = _ArrayCreate("")
    Global $playing = 0
    Global $num = 0
    Global $sleep = 1000 / 15
    Global $asc = True
    Global $dir = "null"
    Global $Pics_Num = 0
    Global $file = ""
    Global $fullscreen = 0
    Global $Pic_Left = 16
    Global $Pic_Top = 24
    Global $Pic_Width = 400
    Global $Pic_Height = 300
    Global $time
    Global $DefaultFileType = ".JPG"
    Global $paused = 0
    Global $sound = ""
    Global $audio = 0
EndFunc
Call("Declarations")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Animator", 651, 478, 196, 120)
$Button1 = GUICtrlCreateButton("Play", 280, 404, 97, 49, 0)
$reset = GUICtrlCreateButton("Reset", 380, 404, 97, 49)
$reverse = GUICtrlCreateButton("Reverse", 180, 404, 97, 49)
$menu = GUICtrlCreateMenu("Options")
$load = GUICtrlCreateMenuItem("Load Folder", $menu)
;$loadin = GUICtrlCreateMenuItem("Load Individual Images", $menu)
$audio = GUICtrlCreateMenuItem("Add Audio", $menu)
$fps = GUICtrlCreateMenuItem("Frames Per Second", $menu)
$trackbar = GUICtrlCreateSlider(10, 378, 631, 20)
GUICtrlSetLimit(-1, 1, 0)
$Pic1 = GUICtrlCreatePic("", 16, 24, 400, 300)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $reset
            Call("Declarations")
            GUICtrlSetLimit($trackbar, 1, 0)
        Case $audio
            $audio = 1
            $audiofile = FileOpenDialog("Open Audio File", "", "Audio Files (*.wav;*.mp3)")
            $sound = _SoundOpen($audiofile)
        Case $trackbar
            If $dir <> "null" Then
                GUICtrlDelete($Pic1)
                GUICtrlCreatePic($dir & "\" & $pics[GUICtrlRead($trackbar)], 16, 24, 400, 300)
                $num = GUICtrlRead($trackbar)
            EndIf
        Case $reverse
            If $asc = True Then
                $asc = False
            Else
                $asc = True
            EndIf
        Case $fps
            $sleep = 1000 / InputBox("Frames Per Second", "Enter the frames per second at which the images will be displayed.", "15")
        Case $load
            $dir = FileSelectFolder("Select the folder from which to load the images.", "")
            If Not @error Then
                $pics = _ArrayCreate("")
                $searchstring = FileFindFirstFile($dir & "\*" &  InputBox("File Extension", "Input the file extension for the images you wish to load. Please note that the extension is case sensetive.", $DefaultFileType))
                If not @error Then
                    $Pics_Num = 1
                    While 1
                        $next = FileFindNextFile($searchstring)
                        If @error then
                            ExitLoop
                        Else
                            _ArrayAdd($pics, $next)
                            $Pics_Num += 1
                        EndIf
                    WEnd
                    GUICtrlSetLimit($trackbar, $Pics_Num - 1, 0)
                    If MsgBox(4, "Ascending or Descending", "Choose what order the images should be sorted and played. Yes for ascending and No for descending.") = 6 Then
                        $asc = True
                        $num = 1
                    Else
                        $num = $Pics_Num
                        $asc = False
                    EndIf
                EndIf
            EndIf
        Case $Button1
            If $playing = 0 Then
                $playing = 1
                GUICtrlSetData($Button1, "Pause")
                If $audio = 1 Then
                    If $paused = 0 Then
                        _SoundPlay($sound)
                    Else
                        _SoundResume($sound)
                    EndIf
                EndIf
            Else
                $playing = 0
                GUICtrlSetData($Button1, "Play")
                $paused = 1
                If $audio = 1 Then
                    _SoundPause($sound)
                EndIf
            EndIf
    EndSwitch
    If BitAND($playing = 1, TimerDiff($time) >= $sleep) Then
        If $dir = "null" Then
            MsgBox(0, "Directory", "You need to load a directory. To do this, Click on Options and then click on Load Folder.")
            $playing = 0
        Else
            If $asc = True Then
                GUICtrlDelete($Pic1)
                $Pic1 = GUICtrlCreatePic($dir & "\" & $pics[GUICtrlRead($trackbar)], $Pic_Left, $Pic_Top, $Pic_Width, $Pic_Height)
                $num = $num + 1
                If $num = $Pics_Num Then
                    $num = 1
                    _SoundStop($sound)
                    _SoundPlay($sound)
                EndIf
                GUICtrlSetData($trackbar, $num)
                $time = TimerInit()
            Else
                GUICtrlDelete($Pic1)
                $Pic1 = GUICtrlCreatePic($dir & "\" & $pics[GUICtrlRead($trackbar)], $Pic_Left, $Pic_Top, $Pic_Width, $Pic_Height)
                $num  = $num - 1
                If $num = 1 Then
                    $num = $Pics_Num
                    _SoundStop($sound)
                    _SoundPlay($sound)
                EndIf
                GUICtrlSetData($trackbar, $num)
                $time = TimerInit()
            EndIf
        EndIf
    EndIf
    If BitAND($fullscreen = 1, _IsPressed("01")) Then
        $fullscreen = 0
        $Pic1 = $old
        GUIDelete($fs)
        $Pic_Left = 16
        $Pic_Top = 24
        $Pic_Width = 400
        $Pic_Height = 300
    EndIf
WEnd

Func fullscreen ()
    $fullscreen = 1
    Global $fs = GUICreate("Animator", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
    Global $old = $Pic1
    $Pic1 = GUICtrlCreatePic("", 0, 0, @DesktopWidth, @DesktopHeight)
    $playing = 1
    GUISetState(@SW_SHOW, $fs)
    $Pic_Left = 0
    $Pic_Top = 0
    $Pic_Width = @DesktopWidth
    $Pic_Height = @DesktopHeight
EndFunc
Edited by BananaFredSoft
Link to comment
Share on other sites

I'm not sure how else to describe it. You can load a folder and sort the images, add audio, change frames per second, and go into full screen. The key combination for full screen is Alt+Enter. I suppose it would also work as a slide show program :whistle:

Suggestions/comments appreciated!

#include <GUIConstants.au3>
#include <Array.au3>
#include <Misc.au3>
#include <Sound.au3>

HotKeySet("!{ENTER}", "fullscreen")

Func Declarations ()
    Global $pics = _ArrayCreate("")
    Global $playing = 0
    Global $num = 0
    Global $sleep = 1000 / 15
    Global $asc = True
    Global $dir = "null"
    Global $Pics_Num = 0
    Global $file = ""
    Global $fullscreen = 0
    Global $Pic_Left = 16
    Global $Pic_Top = 24
    Global $Pic_Width = 400
    Global $Pic_Height = 300
    Global $time
    Global $DefaultFileType = ".JPG"
    Global $paused = 0
    Global $sound = ""
    Global $audio = 0
EndFunc
Call("Declarations")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Animator", 651, 478, 196, 120)
$Button1 = GUICtrlCreateButton("Play", 280, 404, 97, 49, 0)
$reset = GUICtrlCreateButton("Reset", 380, 404, 97, 49)
$reverse = GUICtrlCreateButton("Reverse", 180, 404, 97, 49)
$menu = GUICtrlCreateMenu("Options")
$load = GUICtrlCreateMenuItem("Load Folder", $menu)
;$loadin = GUICtrlCreateMenuItem("Load Individual Images", $menu)
$audio = GUICtrlCreateMenuItem("Add Audio", $menu)
$fps = GUICtrlCreateMenuItem("Frames Per Second", $menu)
$trackbar = GUICtrlCreateSlider(10, 378, 631, 20)
GUICtrlSetLimit(-1, 1, 0)
$Pic1 = GUICtrlCreatePic("", 16, 24, 400, 300)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $reset
            Call("Declarations")
            GUICtrlSetLimit($trackbar, 1, 0)
        Case $audio
            $audio = 1
            $audiofile = FileOpenDialog("Open Audio File", "", "Audio Files (*.wav;*.mp3)")
            $sound = _SoundOpen($audiofile)
        Case $trackbar
            If $dir <> "null" Then
                GUICtrlDelete($Pic1)
                GUICtrlCreatePic($dir & "\" & $pics[GUICtrlRead($trackbar)], 16, 24, 400, 300)
                $num = GUICtrlRead($trackbar)
            EndIf
        Case $reverse
            If $asc = True Then
                $asc = False
            Else
                $asc = True
            EndIf
        Case $fps
            $sleep = 1000 / InputBox("Frames Per Second", "Enter the frames per second at which the images will be displayed.", "15")
        Case $load
            $dir = FileSelectFolder("Select the folder from which to load the images.", "")
            If Not @error Then
                $pics = _ArrayCreate("")
                $searchstring = FileFindFirstFile($dir & "\*" &  InputBox("File Extension", "Input the file extension for the images you wish to load. Please note that the extension is case sensetive.", $DefaultFileType))
                If not @error Then
                    $Pics_Num = 1
                    While 1
                        $next = FileFindNextFile($searchstring)
                        If @error then
                            ExitLoop
                        Else
                            _ArrayAdd($pics, $next)
                            $Pics_Num += 1
                        EndIf
                    WEnd
                    GUICtrlSetLimit($trackbar, $Pics_Num - 1, 0)
                    If MsgBox(4, "Ascending or Descending", "Choose what order the images should be sorted and played. Yes for ascending and No for descending.") = 6 Then
                        $asc = True
                        $num = 1
                    Else
                        $num = $Pics_Num
                        $asc = False
                    EndIf
                EndIf
            EndIf
        Case $Button1
            If $playing = 0 Then
                $playing = 1
                GUICtrlSetData($Button1, "Pause")
                If $audio = 1 Then
                    If $paused = 0 Then
                        _SoundPlay($sound)
                    Else
                        _SoundResume($sound)
                    EndIf
                EndIf
            Else
                $playing = 0
                GUICtrlSetData($Button1, "Play")
                $paused = 1
                If $audio = 1 Then
                    _SoundPause($sound)
                EndIf
            EndIf
    EndSwitch
    If BitAND($playing = 1, TimerDiff($time) >= $sleep) Then
        If $dir = "null" Then
            MsgBox(0, "Directory", "You need to load a directory. To do this, Click on Options and then click on Load Folder.")
            $playing = 0
        Else
            If $asc = True Then
                GUICtrlDelete($Pic1)
                $Pic1 = GUICtrlCreatePic($dir & "\" & $pics[GUICtrlRead($trackbar)], $Pic_Left, $Pic_Top, $Pic_Width, $Pic_Height)
                $num = $num + 1
                If $num = $Pics_Num Then
                    $num = 1
                    _SoundStop($sound)
                    _SoundPlay($sound)
                EndIf
                GUICtrlSetData($trackbar, $num)
                $time = TimerInit()
            Else
                GUICtrlDelete($Pic1)
                $Pic1 = GUICtrlCreatePic($dir & "\" & $pics[GUICtrlRead($trackbar)], $Pic_Left, $Pic_Top, $Pic_Width, $Pic_Height)
                $num  = $num - 1
                If $num = 1 Then
                    $num = $Pics_Num
                    _SoundStop($sound)
                    _SoundPlay($sound)
                EndIf
                GUICtrlSetData($trackbar, $num)
                $time = TimerInit()
            EndIf
        EndIf
    EndIf
    If BitAND($fullscreen = 1, _IsPressed("01")) Then
        $fullscreen = 0
        $Pic1 = $old
        GUIDelete($fs)
        $Pic_Left = 16
        $Pic_Top = 24
        $Pic_Width = 400
        $Pic_Height = 300
    EndIf
WEnd

Func fullscreen ()
    $fullscreen = 1
    Global $fs = GUICreate("Animator", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
    Global $old = $Pic1
    $Pic1 = GUICtrlCreatePic("", 0, 0, @DesktopWidth, @DesktopHeight)
    $playing = 1
    GUISetState(@SW_SHOW, $fs)
    $Pic_Left = 0
    $Pic_Top = 0
    $Pic_Width = @DesktopWidth
    $Pic_Height = @DesktopHeight
EndFunc
Good work, but not useful. Image is too flashy, not smoothly changed, PowerPoint can already do the job.

Thanks for the input though.

Link to comment
Share on other sites

PowerPoint could be any less flashy?

Good work, but not useful. Image is too flashy, not smoothly changed, PowerPoint can already do the job.

Thanks for the input though.

Link to comment
Share on other sites

PowerPoint could be any less flashy?

PowerPoint supports way better animation, at least i don't feel like flashy. I loaded around 10 screenshots and i see a big gap on blank image which shows the bg color, even i set the FPS to 150 it became more flashy. If possible you can make the image fade away trasparently and then fade in that would be good, else i did not find this useful in any place.
Link to comment
Share on other sites

Maybe creating all of the Pic controls, but hidden, and then showing them in order would work?

PowerPoint supports way better animation, at least i don't feel like flashy. I loaded around 10 screenshots and i see a big gap on blank image which shows the bg color, even i set the FPS to 150 it became more flashy. If possible you can make the image fade away trasparently and then fade in that would be good, else i did not find this useful in any place.

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...