Jump to content

Animated Gif's


Dampe
 Share

Recommended Posts

My apologies if this has been posted thousands of times, but is there a way I can animate a gif on the AutoIt Gui?

thanks.

I maybe wrong, but I think you need to convert the animated gif to an avi file and then run it as an avi. There are plenty of free convertors available online.

Link to comment
Share on other sites

Hallo Locutus243

Not directly with native autoit3 functions but to embed into a autoit3 window with a freeware activex component - easy

$oRP = ObjCreate("Gif89.Gif89")
If IsObj($oRP) Then
  GUICtrlCreateObj($oRP,x location,y location,width,height)
  $oRP.filename = pic.gif
endif

Remember to free the component like at exit point

$oRP = 0

You need to copy Gif89.dll to known location like system32 directory and registre the component with 'regsvr32 C:\WINDOWS\system32\Gif89.dll'

You can get the component from this link

http://www.martin2k.co.uk/vb6/ocxs/gif89.zip

kjactive :)

Edited by kjactive
Link to comment
Share on other sites

Hallo Locutus243

Not directly with native autoit3 functions but to embed into a autoit3 window with a freeware activex component - easy

$oRP = ObjCreate("Gif89.Gif89")
If IsObj($oRP) Then
  GUICtrlCreateObj($oRP,x location,y location,width,height)
  $oRP.filename = pic.gif
endif

Remember to free the component like at exit point

$oRP = 0

You need to copy Gif89.dll to known location like system32 directory and registre the component with 'regsvr32 C:\WINDOWS\system32\Gif89.dll'

You can get the component from this link

http://www.martin2k.co.uk/vb6/ocxs/gif89.zip

kjactive :)

Thanks for that kjactive, it works well.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

think i will probably just convert my gif's to avi's

Well you do that, but I should mention that the gif89 component has by other commands, a stop command as well as a speed, Glass, autostart on/off and option to change autosize durring playing...

kjactive :)

Link to comment
Share on other sites

Well you do that, but I should mention that the gif89 component has by other commands, a stop command as well as a speed, Glass, autostart on/off and option to change autosize durring playing...

kjactive :)

Can you give any more information or links?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hallo Martin

I dropped a auto generated .chm topics file containing all Methods and properties at this address

http://www.sitecenter.dk/latenight/nss-fol...nload/gif89.zip

Hope this would do - it's a rather old component but works quiet well...

kjactive :)

Hi kjactive,

thanks for the help file. The methods work fine but with the properties I only had success with the Autostart and I am lost with the others.

What does this mean for example?

object.AutoSize(rhs As Boolean) [= value];rhs As Boolean??

The AutoSize property syntax has these parts:

Part Description

object An expression evaluating to an object of type Gif89a. ;ok

value A No Return Value value. ;??

The speed property changes if I set it like this

$oRP.speed = 20

but there is no change in the speed of the animation.

Also embed, glass, well everything else, is a mystery to me.

But it's not a big deal because the Autostart, Play and Stop are the main things I would like to use.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Well 'Graphics Interchange Format' or Gif - is a group of different formats as Gif87a and gif89a etc., one of the difference between these two common formats is that gif89 can be made transparent IF the graphic file is created in this format ( Glass ) and the Gif89.dll component make use of these extended options too...

I don't know if all methods and properties actually work in autoit3 com interface by SvenP but should do, what I do know is that the order of commands is vital as autostart and autosize must come before the fileload to make a proper action...

kjactive :)

Edited by kjactive
Link to comment
Share on other sites

Well 'Graphics Interchange Format' or Gif - is a group of different formats as Gif87a and gif89a etc., one of the difference between these two common formats is that gif89 can be made transparent IF the graphic file is created in this format ( Glass ) and the Gif89.dll component make use of these extended options too...

I don't know if all methods and properties actually work in autoit3 com interface by SvenP but should do, what I do know is that the order of commands is vital as autostart and autosize must come before the fileload to make a proper action...

kjactive ;)

Thanks :)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 1 month later...

I converted the AniGIF-Wrapper from AutoHotkey to AutoIt: (http://www.autohotkey.com/forum/topic19264.html) It's not perfect, but its no OCX.

Problems: No Transparent Windows :D

#include<GUIConstantsEx.au3>
#include<WindowsConstants.au3>
#cs

Add a AniGif control to your AutoIT Gui.
AniGif by akyprian: http://www.winasm.net/forum/index.php?showtopic=279
From his source file:
;|AniGIF is a copyright of Antonis Kyprianou.                             |
;|                                                                        |
;|You can use AniGIF for NON commercial purposes provided you             |
;|have the following information on your application's about box:         |
;|AniGIF control is copyright of Antonis Kyprianou (http://www.winasm.net)|
;|                                                                        |
;|You need my WRITTEN permission to use AniGIF in commercial applications |

// by Philippe Lhoste <PhiLho(a)GMX.net> http://Phi.Lho.free.fr
// File/Project history:
 1.03.000 -- 2007/05/17 (PL) -- Total encapsulation.
 1.02.000 -- 2007/05/16 (PL) -- Changed functions names (thanks majkinetor), added more wrappers, freed correctly DLL.
 1.01.000 -- 2007/05/16 (PL) -- Update to 1.0.4.0 with WAGM_SETBKCOLOR.
 1.00.000 -- 2007/05/16 (PL) -- Creation.
#ce
#cs Copyright notice: For details, see the following file:
http://Phi.Lho.free.fr/softwares/PhiLhoSoft/PhiLhoSoftLicence.txt
This program is distributed under the zlib/libpng license.
Copyright (c) 2007 Philippe Lhoste / PhiLhoSoft
#ce

#cs*
 * 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.
 #ce
 Global $AniGif_CreateControl_hAniGif
Func AniGif_CreateControl($_guiHwnd, $_x, $_y, $_w, $_h, $_style="")

    local $hAniGif, $agHwnd
    local $msg, $style

    If (Not IsDeclared("AniGif_CreateControl_bFirstCall")) Then
    
        Global $AniGif_CreateControl_bFirstCall = False
        ; It will be unloaded at script end
        $AniGif_CreateControl_hAniGif = DllOpen("AniGif.dll")
    EndIf

    $style = 0
    If ($_style <> "") Then
    
        If StringInStr($_style,"autosize") Then _
            $style += 1 ; WAGS_AUTOSIZE
        If StringInStr($_style,"center") Then _
            $style += 2 ; WAGS_CENTER
        If StringInStr($_style,"hyperlink") Then _
            $style += 4 ; WAGS_HYPERLINK
    EndIf
        ; WS_CHILD | WS_VISIBLE
    $style = BitOR(0x50000000 , $style)

    ; http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/createwindowex.asp
    $agHwnd = DLLCall("User32.dll","hwnd","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 (@error <> 0 or Not IsArray($agHwnd)) Then
    MsgBox(0, '', @error)
        ;msg = %msg% Cannot create AniGif control (%ErrorLevel%/%A_LastError%)
        Return SetError(@error,0,0)
    EndIf

    Return $agHwnd[0]

EndFunc
#cs*
 * Function to call before exiting or destroying the GUI.
 #ce
 Func AniGif_DestroyControl($_agHwnd)
;AniGif_DestroyControl(_agHwnd)
    If ($_agHwnd <> 0) Then
    
        AniGif_UnloadGif($_agHwnd)
        DllCall("User32.dll","long","DestroyWindow", "UInt", $_agHwnd)
    EndIf
EndFunc


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

#cs*
 * After control creation, allows to load the indicated file.
 #ce
Func AniGif_LoadGifFromFile($_agHwnd, $_gifFile)

    ; WAGM_LOADGIFFROMFILE EQU WAGM_BASE+0  ;wParam:N/A,        lParam:lpFileName
;~  SendMessage 2024, 0, &_gifFile, , ahk_id %_agHwnd%
    _AniGIF_SendMessage($_agHwnd,2024,0,$_gifFile,0,"wparam","str")
EndFunc

; Skipped WAGM_LOADGIFFROMRESOURCE  EQU WAGM_BASE+1 ;wParam:hInstance,  lParam:ResourceID

#cs*
 * Probably free memory used by the loaded Gif.
 #ce
Func AniGif_UnloadGif($_agHwnd)

    ; WAGM_UNLOADGIF EQU WAGM_BASE+2    ;wParam:N/A,        lParam:N/A
;~  SendMessage 2026, 0, 0, , ahk_id %_agHwnd%
    _AniGIF_SendMessage($_agHwnd,2026,0,0)
EndFunc

#cs*
 * Set the URL of the hyperlink called when clicking on the Gif.
 * The control must be created with the 'hyperlink' style.
 #ce
Func AniGif_SetHyperlink($_agHwnd, $_url)

    ; WAGM_SETHYPERLINK EQU WAGM_BASE+3 ;wParam:N/A,        lParam:lpszHyprelink
;~  SendMessage 2027, 0, &_url, , ahk_id %_agHwnd%
    _AniGIF_SendMessage($_agHwnd,2027,0,$_url,"wparam","str")
EndFunc

#cs*
 * Zoom in (_bZoomIn = 1) or zoom out (bZoomIn = 0) the given Gif by steps of 10%.
 #ce
Func AniGif_Zoom($_agHwnd, $_bZoomIn)

    ; WAGM_ZOOM EQU WAGM_BASE+4 ;wParam:N/A,        lParam:TRUE(Zoom In by 10%)/FALSE(Zoom Out by 10%)
;~  PostMessage 2028, 0, _bZoomIn, , ahk_id %_agHwnd%
    _AniGIF_SendMessage($_agHwnd,2028,0,$_bZoomIn)
EndFunc

#cs*
 * Change background color of the Gif (if it has transparency or if it is smaller than the control).
 * Color is in BGR format (ie. 0xFF8800 sets blue to FF, green to 88 and red to 00).
 #ce
Func AniGif_SetBkColor($_agHwnd, $_backColor)

    ; WAGM_SETBKCOLOR EQU WAGM_BASE+5   ;wParam:N/A,        lParam:BkColor
;~  PostMessage 2029, 0, _backColor, , ahk_id %_agHwnd%
    _AniGIF_SendMessage($_agHwnd,2029,0,$_backColor)
EndFunc

;-----8<----- For real use, just remove the part below before including the file ----------
; Run test code only if the file is ran standalone

If Not FileExists("AniGif.dll") Then
    InetGet("http://autohotkey.net/~PhiLho/AniGIF.dll", "AniGIF.dll")
    InetGet("http://autohotkey.net/~PhiLho/Images/Flag_France.gif", "Flag_France.gif")
    InetGet("http://autohotkey.net/~PhiLho/Images/pacman.gif", "pacman.gif")
    InetGet("http://autohotkey.net/~PhiLho/Images/teleport.gif", "teleport.gif")
    InetGet("http://autohotkey.net/~PhiLho/Images/Earth.gif", "Earth.gif")
EndIf


#region - GUI Create
$guiID = GUICreate('hi',500,300,-1,-1)

$hAniGif1 = AniGif_CreateControl($guiID, 10, 10, 49, 20)

$hAniGif2 = AniGif_CreateControl($guiID, 70, 10, 38, 28)

$hAniGif3 = AniGif_CreateControl($guiID, 120, 10, 80, 50, "hyperlink center")

GUICtrlCreatePic("D:\Dokumente\Dateien von Andreas\Eigene Bilder\Avatar-MR.bmp", 220, 10, 150, 150)
GUICtrlSetState(-1,@SW_DISABLE)
$hAniGif4 = AniGif_CreateControl($guiID, 220, 10, 150, 150, "center")
WinSetTrans($hAniGif4,"",12)
AniGif_SetBkColor($hAniGif4, 0)

GUISetState()

AniGif_LoadGifFromFile($hAniGif1, "pacman.gif")

AniGif_LoadGifFromFile($hAniGif2, @ScriptDir & "\Flag_France.gif")
AniGif_SetBkColor($hAniGif2, 0xFFAA88)

AniGif_LoadGifFromFile($hAniGif3, @ScriptDir & "\teleport.gif")
AniGif_SetBkColor($hAniGif3, 0xBBCCBB)
AniGif_SetHyperlink($hAniGif3, "http://www.autoit.de")

AniGif_LoadGifFromFile($hAniGif4, @ScriptDir & "\Earth.gif")

$Control_AniGif_Show = GUICtrlCreateButton("OK",10,200,50)
$Control_AniGif_ZoomIn = GUICtrlCreateButton("+",230,200,20)
$Control_AniGif_ZoomOut = GUICtrlCreateButton("-",250,200,20)
$Control_AniGif_Exit = GUICtrlCreateButton("Cancel",70,200,50)

#endregion

#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Control_AniGif_Show 
            MsgBox(0, 'hAniGifModule 1 - 2 - 3 - 4', $hAniGif1 &" "&$hAniGif2&" "&$hAniGif3&" "&$hAniGif4)
        Case $msg = $Control_AniGif_ZoomIn
            AniGif_Zoom($hAniGif4, 1)
        Case $msg = $Control_AniGif_ZoomOut
            AniGif_Zoom($hAniGif4, 0)
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Control_AniGif_Exit
            AniGif_DestroyControl($hAniGif1)
            AniGif_DestroyControl($hAniGif2)
            AniGif_DestroyControl($hAniGif3)
            AniGif_DestroyControl($hAniGif4)
            DllClose($AniGif_CreateControl_hAniGif)
            Exit
    EndSelect
WEnd
#endregion

Func _AniGIF_SendMessage($hWnd, $iMsg, $wParam = 0, $lParam = 0, $iReturn = 0, $wParamType = "wparam", $lParamType = "lparam", $sReturnType = "lparam")
    Local $aResult = DllCall("user32.dll", $sReturnType, "SendMessage", "hwnd", $hWnd, "int", $iMsg, $wParamType, $wParam, $lParamType, $lParam)
    If @error Then Return SetError(@error, @extended, "")
    If $iReturn >= 0 And $iReturn <= 4 Then Return $aResult[$iReturn]
    Return $aResult
EndFunc   ;==>_AniGIF_SendMessage

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

; Animated Gif
; Author - gafrost

Opt("MustDeclareVars", 1)
#include <IE.au3>

_Main()

Func _Main()
    Local $pheight = 50, $pwidth = 50, $oIE, $GUIActiveX, $gif
    $gif = FileOpenDialog("Select Animated Gif", @ScriptDir, "gif files (*.gif)", 3)
    If @error Then Exit
    _GetGifPixWidth_Height($gif, $pwidth, $pheight)
    $oIE = ObjCreate("Shell.Explorer.2")
    GUICreate("Embedded Web control Test", 640, 580)
    $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, $pwidth, $pheight)
    $oIE.navigate ("about:blank")
    While _IEPropertyGet($oIE, "busy")
        Sleep(100)
    WEnd
    $oIE.document.body.background = $gif
    $oIE.document.body.scroll = "no"
    GUISetState()
    While GUIGetMsg() <> -3
    WEnd
EndFunc   ;==>_Main

Func _GetGifPixWidth_Height($s_gif, ByRef $pwidth, ByRef $pheight)
    If FileGetSize($s_gif) > 9 Then
        Local $sizes = FileRead($s_gif, 10)
        ConsoleWrite("Gif version: " & StringMid($sizes, 1, 6) & @LF)
        $pwidth = Asc(StringMid($sizes, 8, 1)) * 256 + Asc(StringMid($sizes, 7, 1))
        $pheight = Asc(StringMid($sizes, 10, 1)) * 256 + Asc(StringMid($sizes, 9, 1))
        ConsoleWrite($pwidth & " x " & $pheight & @LF)
    EndIf
EndFunc   ;==>_GetGifPixWidth_Height

there is a lot more here...

http://www.autoitscript.com/forum/index.ph...st&p=242515

8)

NEWHeader1.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...