How to add a video to a GUI

Put simple Tips and Tricks that are not entire Tutorials in this forum
ymnmwpu7
Posts: 12
Joined: 25 Oct 2019, 20:15

How to add a video to a GUI

25 Oct 2019, 21:06

It works pretty well but it sometimes freezes and stutters and the time between frames can be slightly inconsistent
You need a folder full of image files, .jpg is recommended. The pictures need to be named in increments of 1, for example 1.jpg, 2.jpg, 3.jpg, 4.jpg...

Video of it running: https streamable.com /skr44

My code (sorry it's messy, I haven't had much time to work on it):

Code: Select all

#SingleInstance, Force
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

Process, priority, , Realtime

SetControlDelay, -1

Frames := 13209 ; this is the number of frames (individual pictures) in your folder
Count := 1 ; this is the starting frame/image

Gui, 3:-Caption +ToolWindow

Gui, 3:Add, Picture, x0 y0 w720 h405 vSwap, C:\Users\%A_UserName%\Documents\Flipbook\ (%Count%).jpg

Gui, 3:Show, w720 h405
Gui, 3:Color, F0F0F0
Gui, 1:Color, F0F0F0
Gui, 2:Color, F0F0F0

Gui, 1:-Caption +ToolWindow
Gui, 1:Add, Picture, x0 y0 w720 h405 vSwap, C:\Users\%A_UserName%\Documents\Flipbook\ (%Count%).jpg
Gui, 1:Show, w720 h405

Gui, 1:+LastFound
WinSet, TransColor, F0F0F0 255

Gui, 2:+LastFound
WinSet, TransColor, F0F0F0 255

Gui, 2:-Caption +ToolWindow
Gui, 2:Add, Picture, x0 y0 w720 h405 vSwap, C:\Users\%A_UserName%\Documents\Flipbook\ (%Count%).jpg
Gui, 2:Show, w720 h405

GoSub, Loop
Return

Loop:
	Critical
	TimePeriod = 3
	SetBatchLines -1
	Loop{
		DllCall("Winmm\timeBeginPeriod", uint, TimePeriod)
		Count +=3 ; increase this number to speed up the video
		GuiControl, 3:, Swap, C:\Users\%A_UserName%\Documents\Flipbook\ (%Count%).jpg
		DllCall("Sleep", UInt, 1)
		GuiControl, 1:, Swap, C:\Users\%A_UserName%\Documents\Flipbook\ (%Count%).jpg
		DllCall("Sleep", UInt, 1)
		GuiControl, 2:, Swap, C:\Users\%A_UserName%\Documents\Flipbook\ (%Count%).jpg
		if(Frames <= Count){
			Count := 0
			}
		DllCall("Winmm\timeEndPeriod", UInt, TimePeriod)
		}

	Return

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 6 guests