Sign in to follow this  
Followers 0
peter1234

animated GIFs

11 posts in this topic

I have not been able to get animated GIFs to work in AutoIt. They only show the first frame. Is there some reason why they will not work in AutoIt? If not, can someone give me an example of how to use them? No useful results using search. Thanks.

Share this post


Link to post
Share on other sites



You could make an IE object the size of the picture and navigate to a file that has image tags that point to the animated picture...

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

This:

<body bgcolor="ECE9D8" marginheight="0" topmargin="0" vspace="0" marginwidth="0" leftmargin="0" hspace="0" style="margin:0; padding:0; overflow:hidden;"><img src="animated pic.gif" /></body>

would work for transparent gifs and make the margens 0... Just replace "animated pic.gif" with the picture.

To get the page onto a GUI use something like in this example:

Opt("ExpandVarStrings", 1)
$oIE = ObjCreate("Shell.Explorer.2")
GUICreate( "Embedded Web control Test", 640, 580, (@DesktopWidth-640)/2, (@DesktopHeight-580)/2)
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 640, 580)
$oIE.navigate("@ScriptDir@\animated.html")
GUISetState()
While GUIGetMsg() <> -3
WEnd
Basically ObjCreate() then GUICtrlCreateObj() to the size of the pic. Then navigate to the html file.

[edit]

O ya... Release the object at the end:

$oIE = 0

[edit2]

Tell me if it works as I don't currently have an animated pic to test it on.

[edit3]

Got rid of the verticle scrollbar.

Edited by gamerman2360

Share this post


Link to post
Share on other sites

@gamerman2360:

Thanks. I will give it a try.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

If you like UDFs to do the work for you:

; Made by Gamerman2360
Func GUICtrlCreateInetPic($filename, $left, $top, $width, $height)
    $oIE = ObjCreate("Shell.Explorer.2")
    $ctrlID = GUICtrlCreateObj($oIE, $left, $top, $width, $height)
    $oIE.navigate("about:blank")
    $oIE.document.write('<base href="' & @WorkingDir & '">' & _
    '<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">' & _
    '<img src="' & $filename & '" /></body>')
    Dim $return[2] = [$ctrlID, $oIE]
    Return $return
EndFunc
Make sure you have the beta.

Edit: Updated since I learned more about the IE object.

Edited by gamerman2360

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Works perfect. Thanks. Note - requires beta.

#include <GuiConstants.au3>
HotKeySet("{ESC}", "Terminate")
Func Terminate()
    $oIE = 0
    Exit 
EndFunc

Opt("ExpandVarStrings", 1)
$oIE = ObjCreate("Shell.Explorer.2")
GUICreate( "Embedded Web control Test", 640, 580, (@DesktopWidth-640)/2, (@DesktopHeight-580)/2)
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 640, 580)
$oIE.navigate("@ScriptDir@\animated.html")
GUISetState()
While GUIGetMsg() <> -3
WEnd

animated.html file

<body bgcolor="ECE9D8" marginheight="0" topmargin="0" vspace="0" marginwidth="0" leftmargin="0" hspace="0" style="margin:0; padding:0; overflow-x:hidden; overflow-y:hidden;"><img src="animated gif.gif" /></body>
Edited by peter1234

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

There are two solutions more gif graphics related, one is to use Cwebpage library and wrapup some html code and last there is the freeware gif activex component - download able from my site with a funny example - checkit out...

CWebpage library animated gif example:

http://www.sitecenter.dk/latenight/nss-fol...e/Au3Update.exe

Gif component funny example from site: download both files

http://www.sitecenter.dk/latenight/nss-folder/download

Both examples come with source code...

kjactive :P

Edited by kjactive

Share this post


Link to post
Share on other sites

@gamerman2360:

I have not been able to get UDF to work. I have tried to debug it but was not able to.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

@gamerman2360:

OK. Got UDF working. FileWrite line needs to have all of HTML in one line.

#include <GuiConstants.au3>
HotKeySet("{ESC}", "Terminate")
Func Terminate()
    $oIE = 0
    Exit 
EndFunc

Func GUICtrlCreateAnimatedPic($filename, $left, $top, $width, $height)
    $ExpandVarStrings = Opt("ExpandVarStrings", 1)
    If FileExists("@TempDir@\temp131.html") Then FileDelete("@TempDir@\temp131.html")
    If FileExists("@TempDir@\temp132.gif") Then FileDelete("@TempDir@\temp132.gif")
    FileWrite("@TempDir@\temp131.html", '<body bgcolor="ECE9D8" marginheight="0" topmargin="0" vspace="0" marginwidth="0" leftmargin="0" hspace="0" style="margin:0; padding:0; overflow:hidden;"><img src="@TempDir@\temp132.gif" /></body>')
    FileCopy($filename, "@TempDir@\temp132.gif")
    $oIE = ObjCreate("Shell.Explorer.2")
    GUICtrlCreateObj($oIE, $left, $top, $width, $height)
    $oIE.navigate("@TempDir@\temp131.html")
    Opt("ExpandVarStrings", $ExpandVarStrings)
EndFunc

GuiCreate("",@DesktopWidth,@Desktopheight,-1,-1)
GUISetState () 

$filename = "C:\animated_gif.gif"
$width = 200
$height = 150
$left = @DesktopWidth/2 - $width/2
$top = @Desktopheight/2 - $height/2
GUICtrlCreateAnimatedPic($filename, $left, $top, $width, $height)

sleep (10000)
$oIE = 0
EXIT
Edited by peter1234

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I wonder why making it to 2 lines made it not work.

[edit]

Ah, I see. I tested this:

Opt("ExpandVarStrings", 1)
    MsgBox(0, "Test", '<body bgcolor="ECE9D8" marginheight="0" topmargin="0" vspace="0" marginwidth="0" ' &_
    'leftmargin="0" hspace="0" style="margin:0; padding:0; overflow:hidden;"><img src="@TempDir@\temp132.gif" /></body>')
And I guess "&_" causes an error. Changed it to "& _" in the UDF. Also changed it so it returns the control ID.

[edit2]

Actually I couldn't decide which to have it return between the ID and the object because you can't really do much with GUICtrlCreateObj()s ID so I made it into an array and returned both.

Edited by gamerman2360

Share this post


Link to post
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
Sign in to follow this  
Followers 0