.gif Animation on gui

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Soft
Posts: 174
Joined: 07 Jan 2015, 13:18
Location: Seoul
Contact:

.gif Animation on gui

Post by Soft » 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: 16954
Joined: 21 Dec 2014, 02:44

Re: .gif Animation on gui

Post by boiler » 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: 47
Joined: 10 Jul 2014, 14:38

Re: .gif Animation on gui

Post by capeably » 18 Feb 2015, 16:18

Very cool. Thank you!

User avatar
Soft
Posts: 174
Joined: 07 Jan 2015, 13:18
Location: Seoul
Contact:

Re: .gif Animation on gui

Post by Soft » 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: 16954
Joined: 21 Dec 2014, 02:44

Re: .gif Animation on gui

Post by boiler » 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: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: .gif Animation on gui

Post by robodesign » 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)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.

robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: .gif Animation on gui

Post by robodesign » 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)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.

User avatar
boiler
Posts: 16954
Joined: 21 Dec 2014, 02:44

Re: .gif Animation on gui

Post by boiler » 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: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: .gif Animation on gui

Post by robodesign » 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)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.

User avatar
boiler
Posts: 16954
Joined: 21 Dec 2014, 02:44

Re: .gif Animation on gui

Post by boiler » 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: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: .gif Animation on gui

Post by robodesign » 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)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.

m3user
Posts: 235
Joined: 17 Jan 2014, 18:11

Re: .gif Animation on gui

Post by m3user » 29 Dec 2020, 12:33

I tried the script above by boiler - just changed the path to my animated gif but it just shows the white empty space without image.
Any hint? I'm using a 4K monitor it this is relevant... thanks!

User avatar
boiler
Posts: 16954
Joined: 21 Dec 2014, 02:44

Re: .gif Animation on gui

Post by boiler » 27 Dec 2021, 14:20

Just tried it again in case something changed with the latest OS updates, and it works fine. I don't have a 4K monitor to test it on. How did you define the path to your gif? Can you show that line of your code?

Edit: I just noticed I answered a post that's about a year old. My notifications show there was a reply from @mackc that is currently no longer there. Perhaps mackc is a new user who edited the post and it is in the approval queue. Or perhaps it was deleted. In any case, my reply was in response to @m3user's post which I am just seeing now.

gregster
Posts: 9014
Joined: 30 Sep 2013, 06:48

Re: .gif Animation on gui

Post by gregster » 27 Dec 2021, 14:29

boiler wrote:
27 Dec 2021, 14:20
Edit: I just noticed I answered a post that's about a year old. My notifications show there was a reply from @mackc that is currently no longer there. Perhaps mackc is a new user who edited the post and it is in the approval queue. Or perhaps it was deleted. In any case, my reply was in response to @m3user's post which I am just seeing now.
yeah, that user mackc was banned for posting spam.

User avatar
boiler
Posts: 16954
Joined: 21 Dec 2014, 02:44

Re: .gif Animation on gui

Post by boiler » 27 Dec 2021, 14:34

Thanks :thumbup:

User avatar
Stinkfoot9
Posts: 51
Joined: 29 May 2022, 12:17

Re: .gif Animation on gui

Post by Stinkfoot9 » 16 Aug 2022, 06:58

@boiler Hi boiler nice gif script simple is best.. I'm going to plug it into my desktop image previewer.

One thing
I resized the image to W500 H-1 But can't figure out how to resize the window to w500 h-1 to match.

User avatar
boiler
Posts: 16954
Joined: 21 Dec 2014, 02:44

Re: .gif Animation on gui

Post by boiler » 16 Aug 2022, 07:14

Stinkfoot9 wrote: I resized the image to W500 H-1 But can't figure out how to resize the window to w500 h-1 to match.
Try getting the size of the control using GuiControlGet, then resize the GUI window accordingly.

Post Reply

Return to “Scripts and Functions (v1)”