.gif Animation on gui

Post your working scripts, libraries and tools
User avatar
Soft
Posts: 174
Joined: 07 Jan 2015, 13:18
GitHub: visionary1
Location: Seoul
Contact:

.gif Animation on gui

18 Feb 2015, 13:48

Original post http://www.autohotkey.com/board/topic/1 ... gui/page-1
All credits goes to him and its creators, not me
I just wanted to keep, and share this nice library!

AniGif.dll enables your gui to animate .gif images

Image

Download (Dll, Library and Example are included)
http://me2.do/G6pXZMwg
AutoHotkey & AutoHotkey_H v1.1.22.07
User avatar
boiler
Posts: 2375
Joined: 21 Dec 2014, 02:44

Re: .gif Animation on gui

18 Feb 2015, 16:01

That's a nice capability. Thanks for posting it. I've seen it before and unfortunately it has usage restrictions that wouldn't let me use if for one of my purposes, so I made a function that allows adding an animated GIF to a GUI with just a simple function call. It will automatically figure out the size of the GIF on its own, so you don't have to, which can be a pain in sizing the ActiveX control so it doesn't create an extra border around your image.

One problem it has is that if you add more than one animated GIF with it, often one of them would be frozen or wouldn't be shown. But if you want just one, this seems to work well. I don't know if the dll-based version you posted will show multiple GIFs without problems.

With this function, you can pass all the standard position and size parameters, and it will return the control name so you can manipulate it as my demo shows (hides and unhides it). You can also specify which GUI to add it to if not the default GUI. It will allow you to add up to 10 GIFs, so add more than one if you'd like to see if it works out for you. They each get their own control name. I'm posting it in case anyone might want a smaller, self-contained, and open-use alternative.

Code: Select all

; Demo the function:
AnimPicFile := A_ScriptDir "\watch your step.gif" ; replace with full path to your gif
Gui, +ToolWindow
Gui, Add, Text, vTextCont, Will hide gif in 3 seconds
AGif := AddAnimatedGIF(AnimPicFile)
Gui, Show
Sleep, 3000
GuiControl,, TextCont, Hidden for 3 seconds
GuiControl, Hide, %AGif%
Gui, Show
Sleep, 3000
GuiControl,, TextCont, It's back
GuiControl, Show, %AGif%
Gui, Show
return

; ****  AddAnimatedGIF function by boiler  ****
; imagefullpath: must be the full path to the animated GIF image file
; x, y: optional strings containing position info that would normally follow x and y options, such as 10, "p+3", "m"
; w, h: optional width and height values that would normally follow w and h options; blank for full size image
; guiname:  optional name of the gui to add the image to if not the main one
;
; function returns the name of the control that was added so that you can modify it (move, hide) with GuiControl
; can add up to animated GIF images.  to increase the limit, add AG11,AG12,... to the global statement
;
AddAnimatedGIF(imagefullpath , x="", y="", w="", h="", guiname = "1")
{
	global AG1,AG2,AG3,AG4,AG5,AG6,AG7,AG8,AG9,AG10
	static AGcount:=0, pic
	AGcount++
	html := "<html><body style='background-color: transparent' style='overflow:hidden' leftmargin='0' topmargin='0'><img src='" imagefullpath "' width=" w " height=" h " border=0 padding=0></body></html>"
	Gui, AnimGifxx:Add, Picture, vpic, %imagefullpath%
	GuiControlGet, pic, AnimGifxx:Pos
	Gui, AnimGifxx:Destroy
	Gui, %guiname%:Add, ActiveX, % (x = "" ? " " : " x" x ) . (y = "" ? " " : " y" y ) . (w = "" ? " w" picW : " w" w ) . (h = "" ? " h" picH : " h" h ) " vAG" AGcount, Shell.Explorer
	AG%AGcount%.navigate("about:blank")
	AG%AGcount%.document.write(html)
	return "AG" AGcount
}

GuiClose:
ExitApp
capeably
Posts: 31
Joined: 10 Jul 2014, 14:38

Re: .gif Animation on gui

18 Feb 2015, 16:18

Very cool. Thank you!
User avatar
Soft
Posts: 174
Joined: 07 Jan 2015, 13:18
GitHub: visionary1
Location: Seoul
Contact:

Re: .gif Animation on gui

18 Feb 2015, 20:17

@boiler / your version is cool!, nicely minimizied.
dll version allow you to animate multiple gif at the same time, and remove used one from gui
AutoHotkey & AutoHotkey_H v1.1.22.07
User avatar
boiler
Posts: 2375
Joined: 21 Dec 2014, 02:44

Re: .gif Animation on gui

18 Feb 2015, 20:36

Thanks, Soft. That's good to know about the dll version. Sounds very robust and useful. That's why I didn't post mine before. It bugged me that it didn't work well with more than one gif, so I didn't think it was worth a new thread. I thought it might have something to do with more than one ActiveX control going at the same time.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: DuyMinh and 46 guests