Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Show animated Gifs in your GUI


  • Please log in to reply
64 replies to this topic
n-l-i-d
  • Guests
  • Last active:
  • Joined: --
In general I am a very patient person, very patient, but I can imagine others becoming less patient if you continue like this, or you might simply get ignored one day, I already warned you about that.

You are definitely right that some changes are necessary, but I think you are only working against improving the situation for all of us, if you keep "calling names".

Calling people "childish/kids/n00bs/unprofessional" and other things is not going to help (but I'm repeating myself now)... it isn't, no matter how "right" you might be...

Understand that everything here is voluntary, and you calling people that offer their free-time to improve this project "unprofessional" or "not-serious" is - again - rude, and will only shun those away.

I don't mind strong language, not at all, but one of the good things of this forum is that usually people refrain from using strong language, and try helping others, even if these other users are new and don't know much yet. The way you are acting around here is quite contrary to this general attitude. So, in your own interest, try keeping it down a bit, it's better for everybody (including myself, I have very egotistical reasons for this opinion). Look at what happened with AutoIt. The snobbish approach of the moderators/coders there made very many people leave... Would't want to happen similar things to AutoHotkey...

:wink:

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006

or you might simply get ignored one day, I already warned you about that.

And how is that different from now ?

but I can imagine others becoming less patient if you continue like this

And they will do what ? Kill me ? Scream at me ? Cmon...

Calling people "childish/kids/n00bs/unprofessional" and other things is not going to help (but I'm repeating myself now)... it isn't, no matter how "right" you might be...

Well, asking them nicely didn't help too. So lets try differently for a change. It is matter of how "right" one is. I am not here to spread cookies but I try to impose some standards here. That is the difference between child and mature man - its seeing the truth between the words.
I am repeating myself now, but instead of talking again, you should do different things and support standardisation with all voices you have. Its no about me either as you constantly say "you this, you that". If U think you have good/bad model for standardisation, say it, and force it, I will support it (and not screming at you: "HEJ, DON'T TELL ME HOW TO PROGRAMM, I AM HERE ON VACATION). Any law, is better then no law.

Understand that everything here is voluntary, and you calling people that offer their free-time to improve this project "unprofessional" or "not-serious" is - again - rude, and will only shun those away.

I tell my stories to power users, not to shy first day scripters.

The snobbish approach of the moderators/coders there made very many people leave

You talk nonsense. I comment each script if nothing else just to say Thx which is something none of you do. Third time, when you go to any warez site and upload anything you wish (even open source program, not necesseraly hacked thing) you will get X thank you's, and messages of support because ppl appriciate your effort although they might have nothing of that. Not something I see here. This community is pretty selfish. PPl comment just things they use and need (not even that) and can't see further then their own simple needs.

So stop talking already and do some real work. My atitutde has nothing to do with AU3 mods attititutde. They don't like n00bs, I use this word to signify something else. I usualy help n00bs when my time allows and generaly don't have anything against them.
Posted Image

Mr.Wolna/NRY
  • Guests
  • Last active:
  • Joined: --
Hi first of all i will thank the authors for this great and wounderfull,amazing work, you did a very nice job, respect.


Days ago i have start to code something like a little AHK Addon for a forum, and i have a little problem with transparancy, first i thouth about to change the background color of the gifs(in the script) the same like the bakcground colour of my application. But the problem is, he did not show the same colour as i need. So i don't know what is all about, meaby its the DLL meaby the pallete. So meaby and i really hope so someone here can help me out my deilemma. Ahmm here a screenshot foor better understending, and sorry for my bad english :oops:

Grettings Mr.Wolna

Mr.Wolna/Again
  • Guests
  • Last active:
  • Joined: --
Oh, i am very sorry folks. I forgot the screeny :oops:

Posted Image

So long
Mr.Wolna

  • Guests
  • Last active:
  • Joined: --
I want to move the GIF animation like "GuiControl, Move,MYPICVAR, x10 y20 w200 h100".

I'am able to zoom but I can't move the GIFs whithout ControlID.
I want to add 2 buttons in "Control_AniGif.ahk" to move a picture like the zoom buttons.

please help

Mr.Wolna/Again
  • Guests
  • Last active:
  • Joined: --

Oh, i am very sorry folks. I forgot the screeny :oops:

Posted Image


So long
Mr.Wolna



hello do you know how can I load local gif

IN TH E SCRIP
;-----8<----- For real use, just remove the part below before including the file ----------
; Run test code only if the file is ran standalone
If (A_ScriptName = "Control_AniGif.ahk")
{

IfNotExist %A_ScriptDir%\AniGIF.dll
{
URLDownloadToFile https://ahknet.autoh...iLho/AniGIF.dll, AniGIF.dll
URLDownloadToFile https://ahknet.autoh...Flag_France.gif, Flag_France.gif
URLDownloadToFile https://ahknet.autoh...ages/pacman.gif, pacman.gif
URLDownloadToFile https://ahknet.autoh...es/teleport.gif, teleport.gif
URLDownloadToFile https://ahknet.autoh...mages/Earth.gif, Earth.gif
}

Gui +LastFound
guiID := WinExist()

ISNTEAD URLDownloadToFile https://ahknet.autoh...Flag_France.gif, Flag_France.gif

I want to use C:\image.gif, image.gif

somebody please help me


:wink:

BkkGuy
  • Guests
  • Last active:
  • Joined: --
Thanks so much for sharing this script, it has been a great help to me.

However, I have recently started using AHK_L Unicode with a larger AutoHotkeySC.bin file because I need to add Thai text to the gui, but when the script is compiled and the .exe is run it always returns a message saying "Error loading file" when it executes the SendMessage statement in the AniGif_LoadGifFromFile function, then it displays the Thai text but without the images.

The only changes I made to the original script were to add one line of Thai text to the gui and to replace the name of the pacman gif image to another gif image which resides in the script folder/directory.

There is no problem if the script is compiled using the AHK Basic version with the smaller AutoHotkeySC.bin file, but the Thai characters are replaced with meaningless ANSI characters.

So I can have either the images without proper Thai text, or Thai text with no images. Does anybody know of a solution to this problem? Any help would be greatly appreciated.

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
I've been successful in making my animated gif work!
Thanks to PhiLho, bigtime. I have one problem though and I've asked on the help section but there have been no replies, I'm thinking because I asked for help incorrectly.
My problem is not making the gif animate, it is placing the working code into my existing GUI. I've tried placing it in many different places (at the beginning, right after the gui is created, at the middle, at the end) and I've tried using #FileInclude from my GUI and from the working gif code but nothing "marries" the two chunks of code so it works together.

I cannot, for the life of me, understand how to incorporate this into my existing GUI.

You will need these three files in the same dir to run this altered demo (credits and thanks to PhiLho):

hal.gif
AniGIF.dll
Control_AniGif.ahk

This is the image, named hal.gif:
Posted Image
...you need the AniGIF.dll file to be in your script dir, download here:
https://ahknet.autoh...iLho/AniGIF.dll
Here is the altered GUI code in which it works, THANK YOU PHILHO btw!!!:
(name it Control_AniGif.ahk)
/**
 * Control creation: you have to provide the ID of the GUI in which the control goes,
 * its position (_x, _y) and size (_w, _h) and optionally additional styles,
 * made of a string with keywords:
 * - autosize to make the control adapts to the Gif size
 * - center to center the Gif in the control
 * - hyperlink to allow clicking on the control and opening the URL defined later
 * Note that the required DLL is loaded automatically on first call.
 */
AniGif_CreateControl(_guiHwnd, _x, _y, _w, _h, _style="0")
{
   local hAniGif, agHwnd
   local msg, style
   static $bFirstCall := true

   If ($bFirstCall)
   {
      $bFirstCall := false
      ; It will be unloaded at script end
      hAniGif := DllCall("LoadLibrary", "Str", "AniGif.dll")
   }

   style := 0
   style := 0x50000000 | style

   ; http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/createwindowex.asp
   agHwnd := DLLCall("CreateWindowEx"
         , "UInt", 0                     ; Style, can be WS_EX_CLIENTEDGE = 0x200
         , "Str", "AniGIF"               ; Class Name
         , "Str", "AnimatedGif"          ; Window name
         , "UInt",  style                ; Window style
         , "Int", _x                     ; X position
         , "Int", _y                     ; Y position
         , "Int", _w                     ; Width
         , "Int", _h                     ; Height
         , "UInt", _guiHwnd              ; Handle of parent
         , "UInt", 0                     ; Menu
         , "UInt", 0               ; hInstance of the module registering the component's class
         , "UInt", 0)                    ; User defined style
   If (ErrorLevel != 0 or agHwnd = 0)
   {
      msg = %msg% Cannot create animated gif
      Gosub AniGif_CreateControl_CleanUp
      Return msg
   }

   Return agHwnd

AniGif_CreateControl_CleanUp:   ; In case of error
Return
}

/**
 * Function to call before exiting or destroying the GUI.
 */
AniGif_DestroyControl(_agHwnd)
{
   If (_agHwnd != 0)
   {
      AniGif_UnloadGif(_agHwnd)
      DllCall("DestroyWindow", "UInt", _agHwnd)
   }
}

;AniGIF control messages
; WM_USER := 0x400 ; 1024
; WAGM_BASE := WM_USER+1000 ; 2024

/**
 * After control creation, allows to load the indicated file.
 */
AniGif_LoadGifFromFile(_agHwnd, _gifFile)
{
   ; WAGM_LOADGIFFROMFILE EQU WAGM_BASE+0   ;wParam:N/A,      lParam:lpFileName
   SendMessage 2024, 0, &_gifFile, , ahk_id %_agHwnd%
}

AniGif_UnloadGif(_agHwnd)
{
   ; WAGM_UNLOADGIF EQU WAGM_BASE+2   ;wParam:N/A,      lParam:N/A
   SendMessage 2026, 0, 0, , ahk_id %_agHwnd%
}


 ; (comment from Aaron: I've tried removing this next part and adding to other GUI with no success)

;-----8<----- For real use, just remove the part below before including the file ----------
; Run test code only if the file is ran standalone
If (A_ScriptName = "Control_AniGif.ahk")
{

Gui +LastFound
guiID := WinExist()

hAniGif1 := AniGif_CreateControl(guiID, 5, 5, 90, 90)
hAniGif2 := AniGif_CreateControl(guiID, 892, 5, 90, 90)

If hAniGif1 is not integer
   MsgBox %hAniGif1%
If hAniGif2 is not integer
   MsgBox %hAniGif2%




    ;   this makes a working GUI for the gif

Gui Show, w987 h99, AniGif demo
Gui, Color, Red





;~ AniGif_LoadGifFromFile(hAniGif1, A_ScriptDir . "\hal.gif")
WideCharToMultiByte("hal.gif",sFileName)
AniGif_LoadGifFromFile(hAniGif1, sFileName)

;~ AniGif_LoadGifFromFile(hAniGif2, A_ScriptDir . "\hal.gif")
WideCharToMultiByte("hal.gif",sFileName)
AniGif_LoadGifFromFile(hAniGif2, sFileName)
Return

WideCharToMultiByte(wChar,Byref sChar) {
VarSetCapacity(sChar,StrLen(wChar)*2)
return DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wChar, "int", -1, "str", sChar, "int", StrLen(wChar)*2, "Uint", 0, "Uint", 0)
}
}
Can I please have someone's help with this? It needs to go in my GUI called "Aaron's Super Google Search"
Thank you very much :)
Aaron

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
never mind I got it :)
except.... I would like to be able to reference the AniGIF.dll file when the file is in a folder named "%temp%\aaron\welcome"
I've changed the paths in "Control_AniGif.ahk" to reflect the temp folder location but all it does is return an error. Am I forced to keep my animated GIF and the AniGIF.dll in the same location as my GUI? I wonder if this would count as a separate "help" request from my first one.

tuna
  • Members
  • 158 posts
  • Last active: Dec 28 2012 04:50 PM
  • Joined: 03 Oct 2007
For me, AniGif_LoadGifFromFile() fails - not too sure why. For the demo I just get

---------------------------
AniGIF
---------------------------
Error loading file.
---------------------------
OK   
---------------------------

Posted Image

I've checked all files are there.

Using Vista 32-bit with AHK_L Unicode. Thanks

  • Guests
  • Last active:
  • Joined: --
I have this working in my gui, but is there anyway to position one animated gif in the center of the screen? I can use coordinates, but I need that it's stays on the center, no matter what screen res is used. Thanx.

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
I was looking for something similar, not for an animated gif but what was shown to me might work for you as well: Attach()

  • Guests
  • Last active:
  • Joined: --
Can you use guicontrol to move the picture?

After 3 hours in front of my computer, I've been able to place an animated gif in my gui! Now, the transparency doesn't work, and I can't figure out a way to place it centered on screen, just above the text string. Any help would be so much appreciated...


#SingleInstance, force

AniGif_CreateControl(_guiHwnd, _x, _y, _w, _h, _style="")
{
	local hAniGif, agHwnd
	local msg, style
	static $bFirstCall := true

	If ($bFirstCall)
	{
		$bFirstCall := false
		hAniGif := DllCall("LoadLibrary", "Str", "AniGif.dll")
	}

	style := 0
	
	style := 0x50000000 | style

	
	agHwnd := DLLCall("CreateWindowEx"
			, "UInt", 0                     ; Style, can be WS_EX_CLIENTEDGE = 0x200
			, "Str", "AniGIF"               ; Class Name
			, "Str", "AnimatedGif"          ; Window name
			, "UInt",  style                ; Window style
			, "Int", _x                     ; X position
			, "Int", _y                     ; Y position
			, "Int", _w                     ; Width
			, "Int", _h                     ; Height
			, "UInt", _guiHwnd              ; Handle of parent
			, "UInt", 0                     ; Menu
			, "UInt", 0               ; hInstance of the module registering the component's class
			, "UInt", 0)                    ; User defined style

	Return agHwnd

Return
}

AniGif_LoadGifFromFile(_agHwnd, _gifFile)
{
	; WAGM_LOADGIFFROMFILE EQU WAGM_BASE+0	;wParam:N/A,		lParam:lpFileName
	SendMessage 2024, 0, &_gifFile, , ahk_id %_agHwnd%
}

AniGif_UnloadGif(_agHwnd)
{
	; WAGM_UNLOADGIF EQU WAGM_BASE+2	;wParam:N/A,		lParam:N/A
	SendMessage 2026, 0, 0, , ahk_id %_agHwnd%
}

AniGif_SetBkColor(_agHwnd, _backColor)
{
	; WAGM_SETBKCOLOR EQU WAGM_BASE+5	;wParam:N/A,		lParam:BkColor
	PostMessage 2029, 0, _backColor, , ahk_id %_agHwnd%
}


Gui, 1: Margin, 0,0
Gui, 1: +LastFound 

Gui, 1: Color, 303030 
Gui, 1: +ToolWindow -Caption
Gui, 1: Show,x0 y0 w%A_ScreenWidth% h%A_ScreenHeight%

Gui, 2: default
Gui, 2: Color, 303030 
Gui, 2: +ToolWindow -Caption
Gui, 2: font, s18 C707070 w700, verdana
Gui, 2: Add, Text, w700 center vremaining ,



guiID := WinExist()

hAniGif1 := AniGif_CreateControl(guiID, 1, 1, 100, 100)

AniGif_LoadGifFromFile(hAniGif1, "search-wait.gif")
AniGif_SetBkColor(hAniGif1, 0xefef)

;GuiControl, Move, MYPICVAR, x100 y200 ??????????


guicontrol,, remaining, Images remaining: %result%

Gui, 2: Show, xcenter ycenter

sleep 2000
exitapp


  • Guests
  • Last active:
  • Joined: --
This should work for centering the image, but it's not... :cry:

Gui +LastFound
guiID := WinExist()
SetFormat, Float, 0.0
xg = %A_ScreenWidth%
yg = %A_ScreenHeight%
xg2 := xg / 2
yg2 := yg / 2
;msgbox, %xg2%
;msgbox, %yg2%
hAniGif2 := AniGif_CreateControl(guiID, %xg2%, %yg2%, 100, 100)
Gui, +ToolWindow -Caption
Gui, Show,x0 y0 w%A_ScreenWidth% h%A_ScreenHeight%, AniGif demo
AniGif_LoadGifFromFile(hAniGif2, A_ScriptDir . "\search-wait.gif")
AniGif_SetBkColor(hAniGif2, 0xefefef)


aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
anigif will lose the gif's transparency so you have to match the background with the background of your gui. I had to do it for Aaron's Super Google (feel free to look at the code for ideas how to place the gifs and background color)