.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: 2920
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: 2920
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.
robodesign
Posts: 530
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: .gif Animation on gui

24 May 2019, 14:04

@boiler

How to change AG1 to a different GIF?

I have a GIF in the User interface and then, on a button push, I want it changed to a different .GIF, with new size and position.

I never want more than one GIF into the UI.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
robodesign
Posts: 530
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: .gif Animation on gui

05 Jun 2019, 16:10

If I add only one GIF into the GUI.... And I try to use....

AG1.navigate("about:blank")
AG1.document.write(html)

The page gets blank (white)....

I'm using an updated html variable....

Code: Select all

 
	html := "<html><body style='background-color: transparent' style='overflow:hidden' leftmargin='0' topmargin='0'><img src='" imageNewFullpath "' width=" w " height=" h " border=0 padding=0></body></html>"


Any suggestions? Thank you.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
User avatar
boiler
Posts: 2920
Joined: 21 Dec 2014, 02:44

Re: .gif Animation on gui

14 Jun 2019, 21:24

Do you have valid values assigned to the variables imageNewFullPath, w, and h prior to your statement where you assign the value to the variable html? If not, you don't have a valid html string.
robodesign
Posts: 530
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: .gif Animation on gui

15 Jun 2019, 07:58

Yes, I do. I feed valid values to the html. Does that work for you?

Right now, I made it such that I recreate the GUI each time I change the GIF animation, however it's utterly dumb.

I can't get it working without recreating the GUI. Any ideas?

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
User avatar
boiler
Posts: 2920
Joined: 21 Dec 2014, 02:44

Re: .gif Animation on gui

15 Jun 2019, 18:21

I haven't tried making that work, but I believe that it would be the same for me. I imagine the way the document object works, it's not meant to have a new html written to it. I recommend adding a second image and switch between them using GuiControl, Hide and GuiControl, Show.
robodesign
Posts: 530
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: .gif Animation on gui

16 Jun 2019, 02:12

Thanks for the suggestion, but in my case that's not a solution, because I'm developing an image viewer..... Therefore it must work with "countless" files, not just two. I'm going to post it soon. (in a week or two)

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Chunjee and 47 guests