elgabionline Posted September 23, 2006 Share Posted September 23, 2006 Hi! I Just trying... My first attempt here: #include <guiconstants.au3> GUICreate ("Show Gif",200,150) _guictrlcreategif ("http://www.autoitscript.com/forum/style_emoticons/autoit/idea.gif",10,10,22,26) GUISetState () While 1 $msg=GUIGetMsg () if $msg=$GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete () filedelete (@tempdir&"\gifload") Exit Func _GUICtrlCreateGif ($s_path,$n_left,$n_top,$n_width,$n_height,$o_Gif=-1) If $o_Gif=-1 Then $o_Gif=ObjCreate ("Shell.Explorer.2") If IsObj ($o_Gif) Then Local $h_control=GUICtrlCreateObj ($o_Gif,$n_left,$n_top,$n_width+4,$n_height+4) $h_file=FileOpen (@TempDir&"\gifload",2) $s_line='<BODY background="'&$s_path&'" Scroll="No">' FileWriteLine ($h_file,"<HTML>") FileWriteLine ($h_file,$s_line) FileWriteLine ($h_file,"</BODY>") FileWriteLine ($h_file,"</HTML>") FileClose ($h_file) $o_Gif.navigate (@TempDir&"\gifload") Return $h_control Else SetError (1) Return False EndIf EndFunc I made this, but it stinks... is there some better way to show animated gifs? I listen for suggestions!! :"> Link to comment Share on other sites More sharing options...
GaryFrost Posted September 23, 2006 Share Posted September 23, 2006 you'll get more help if you post questions in support SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
elgabionline Posted September 23, 2006 Author Share Posted September 23, 2006 you'll get more help if you post questions in support@gafrost: maybe, but that code works. I need opinions to make it better... do you believe that is in wrong place? I was not sure, for that reason I put this code here... whatever, thanks Link to comment Share on other sites More sharing options...
GaryFrost Posted September 23, 2006 Share Posted September 23, 2006 (edited) $oIE = ObjCreate("Shell.Explorer.2") GUICreate("Embedded Web control Test", 640, 580) $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 250, 100) $oIE.navigate (@ScriptDir & '\Happy_Birthday_Gross.gif') $oIE.document.body.scroll = "no" GUISetState() While GUIGetMsg() <> -3 WEnd Edit: Added no scroll so you can see that you can make it any size you want in the gui. Edited September 24, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
GaryFrost Posted September 23, 2006 Share Posted September 23, 2006 (edited) Here's something else you might find interesting when working with gifs _Main() Func _Main() Local $pheight, $pwidth, $oIE, $GUIActiveX, $gif = @ScriptDir & '\Happy_Birthday_Gross.gif' _GetGifPixWidth_Height($gif, $pwidth, $pheight) $oIE = ObjCreate("Shell.Explorer.2") GUICreate("Embedded Web control Test", 640, 580) $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, $pwidth + 16, $pheight + 21) $oIE.navigate ($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 it appears the width is off by 9 pixels on this gif from the formula i found on the web i've tried it with a few others and it seems to be right on the money. Edited September 23, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
elgabionline Posted September 23, 2006 Author Share Posted September 23, 2006 Here's something else you might find interesting when working with gifs 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 it appears the width is off by 9 pixels on this gif from the formula i found on the web i've tried it with a few others and it seems to be right on the money. Yes yes yes... that code works!! and really nice! @gafrost: A lot of thanks for help me with my... "scrap" Link to comment Share on other sites More sharing options...
GaryFrost Posted September 23, 2006 Share Posted September 23, 2006 (edited) Yes yes yes... that code works!! and really nice! @gafrost: A lot of thanks for help me with my... "scrap" yw looks like the ie embedded has an offset edge so it don't actually start the gif on 0,0 but rather 25 pixels from the left and 35 pixels from the top to test it i had a square gif with a dark background to try to get the a frame look around the gif here's what i used: ; add to width and height, ie obj starts the image approx. on those pixel coords $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, $pwidth + 25, $pheight + 35) Edited September 23, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
elgabionline Posted September 24, 2006 Author Share Posted September 24, 2006 (edited) looks like the ie embedded has an offset edge so it don't actually start the gif on 0,0 but rather 25 pixels from the left and 35 pixels from the top Yes.. I can see that. I try with this code, and the edge shouldn't appear. But neither the gif appears! _Main() Func _Main() Local $pheight, $pwidth, $oIE, $GUIActiveX, $gif = @DesktopDir&"\Happy_Birthday_Gross.gif"; I put the image there... :) _GetGifPixWidth_Height($gif, $pwidth, $pheight) $oIE = ObjCreate("Shell.Explorer.2") GUICreate("Embedded Web control Test", 640, 580) $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, $pwidth, $pheight) With $oIE .navigate ("about:blank") .document.body.background=$gif .document.body.scroll = "no" EndWith 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 Depending on the order I puts them in Width-EndWith, scroll bar not appears or the image appears. Not both... Edited September 24, 2006 by elgabionline Link to comment Share on other sites More sharing options...
GaryFrost Posted September 24, 2006 Share Posted September 24, 2006 (edited) Func _Main() Local $pheight, $pwidth, $oIE, $GUIActiveX, $gif = @ScriptDir & '\biplane_landing.gif' _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") $oIE.document.body.background = $gif $oIE.document.body.scroll = "no" GUISetState() While GUIGetMsg() <> -3 WEnd EndFunc ;==>_Main Edited December 29, 2012 by Jon SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
GaryFrost Posted September 24, 2006 Share Posted September 24, 2006 I suspect in using With it doens't apply the settings untill the EndWith and IE may not apply those settings in the order you want them to. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Ed_Maximized Posted September 28, 2006 Share Posted September 28, 2006 I suspect in using With it doens't apply the settings untill the EndWith and IE may not apply those settings in the order you want them to.Thanks both elgabionline & gafrost... good piece of code!!!Is there any way to stop/resume animation? ShapedGUI Creator : Shaped gui the easy way!!!Txt2au3 : the easy way to include text files into your program without fileinstall_GUICreateWithTiledBackground : Put a GIF in the background of your formsSQLite Database BrowserAnimated GIF UDF : Put animations in your GUI's Link to comment Share on other sites More sharing options...
lod3n Posted September 28, 2006 Share Posted September 28, 2006 You can add this to the code to remove the sunken border on the IE object: $oIE.document.body.style.border = "0px" [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
GaryFrost Posted September 28, 2006 Share Posted September 28, 2006 (edited) Almost that easy. expandcollapse popupOpt("MustDeclareVars", 1) #include <GuiConstants.au3> #include <IE.au3> _Main() Func _Main() Local $GUI, $pheight = 50, $pwidth = 50, $oIE, $GUIActiveX, $gif, $btn_toggle, $msg Local $animated = 1, $btn_text[2] = ["Start", "Stop"] $gif = FileOpenDialog("Select Animated Gif", @ScriptDir, "gif files (*.gif)", 3) If @error Then Exit _GetGifPixWidth_Height($gif, $pwidth, $pheight) $oIE = ObjCreate("Shell.Explorer.2") $GUI = GUICreate("Embedded Web control Test", 640, 580) $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, $pwidth, $pheight) _StartGif($GUI, $oIE, $gif) $btn_toggle = GUICtrlCreateButton($btn_text[$animated], ($pwidth / 2) - 45, $pheight + 10, 90, 20) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $btn_toggle $animated = Not $animated GUICtrlSetData($btn_toggle, $btn_text[$animated]) If $animated Then _StartGif($GUI, $oIE, $gif) Else _IEAction($oIE, "stop") ; stop EndIf EndSwitch WEnd EndFunc ;==>_Main Func _StartGif($GUI, $oIE, $gif, $noborder = 0) GUISetState(@SW_LOCK, $GUI) $oIE.navigate ("about:blank") While _IEPropertyGet($oIE, "busy") Sleep(100) WEnd $oIE.document.body.background = $gif $oIE.document.body.scroll = "no" If $noborder Then $oIE.document.body.style.border = "0px" GUISetState(@SW_UNLOCK, $GUI) EndFunc ;==>_StartGif 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 Edited September 28, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Ed_Maximized Posted October 13, 2006 Share Posted October 13, 2006 Until someone of you do something better... I propose this UDF... Functions are: _GUICtrlCreateGIF() ;create an animated gif _GUICtrlStopGIF() ;stops an animation _GUICtrlResumeGIF() ;resume animation This UDF would't be possible without: elgabionline, gafrost and lod3n expandcollapse popup;=============================================================================== ; UDF Name: _AnimatedGif.au3 ; ; Version v1.0.0 Oct 12, 2006, built with Autoit 3.2.1.3 ; ; Authors: gafrost, elgabionline, lod3n ; ; Contribution: Ed_Maximized ; ; Email: <edmundofasano [at] gmail [dot] com> ; ; Use: Creation of an animated GIF control and functions to stop/resume animation ;=============================================================================== #include-once ;=============================================================================== ; ; Function Name: _GUICtrlCreateGIF() ; Description: Create an Animated GIF control ; Parameter(s): $gif [required] path and filename of the animated GIF ; $x [optional] x pos of the top-left corner ; $y [optional] y pos of the top-left corner ; $border [optional] 0 = no border ; any other = sunken border ; Requirement(s): #include <IE.au3> ; Return Value(s): ; controlID of the control created ; Author(s): elgabionline, gafrost, Ed_Maximized ; ;=============================================================================== Func _GUICtrlCreateGIF($gif,$x=0,$y=0,$border=0) Local $pwidth,$pheight,$oIE,$GUIActiveX _GetGifPixWidth_Height($gif, $pwidth, $pheight) $oIE = ObjCreate("Shell.Explorer.2") $GUIActiveX = GUICtrlCreateObj($oIE, $x, $y, $pwidth, $pheight) $oIE.navigate ("about:blank") While _IEPropertyGet($oIE, "busy") Sleep(100) WEnd $oIE.document.body.background = $gif $oIE.document.body.scroll = "no" if $border=0 then $oIE.document.body.style.border = "0px" Return $oIE EndFunc ;=============================================================================== ; ; Function Name: _GUICtrlStopGIF() ; Description: stop an Animated GIF control created with _GUICtrlCreateGIF() ; Parameter(s): $Control [required] controlID of the control returned by _GUICtrlCreateGIF() ; ; Requirement(s): #include <IE.au3> ; Return Value(s): ; none ; Author(s): lod3n, Ed_Maximized ; ;=============================================================================== Func _GUICtrlStopGIF($Control) _IEAction ($Control, "stop" ) ; stop EndFunc ;=============================================================================== ; ; Function Name: _GUICtrlResumeGIF() ; Description: resume an Animated GIF control created with _GUICtrlCreateGIF() ; Parameter(s): $Control [required] controlID of the control returned by _GUICtrlCreateGIF() ; ; Requirement(s): #include <IE.au3> ; Return Value(s): ; none ; Author(s): lod3n, Ed_Maximized ; ;=============================================================================== Func _GUICtrlResumeGIF($Control) $Control.document.body.background = $Control.document.body.background ;resume EndFunc ;=============================================================================== ; ; Function Name: _GetGifPixWidth_Height() ; Description: return the size of a GIF image in pixels ; Parameter(s): $s_gif [required] path and filename of the animated GIF ; ; Requirement(s): #include <IE.au3> ; Return Value(s): ; $pwidth = width of the GIF in pixels ; $pheight = height of the GIF in pixels ; Author(s): gafrost ; ;=============================================================================== 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 oÝ÷ Ù7¬·Øb±ìZ^jëh×6 ; Animated Gif Example ; Author - Ed_Maximized Opt("MustDeclareVars", 1) #include <IE.au3> #include <GUIConstants.au3> #include <_AnimatedGIF.au3> _Main() Func _Main() Local $pheight = 50, $pwidth = 50, $gif, $gif_control, $Form1, $Button1, $Button2, $msg $gif = FileOpenDialog("Select Animated Gif", @ScriptDir, "gif files (*.gif)", 3) If @error Then Exit $Form1 = GUICreate("Animated GIF demo", 622, 448, 192, 125) $Button1 = GUICtrlCreateButton("Stop", 8, 8, 81, 25) $Button2 = GUICtrlCreateButton("Resume", 96, 8, 81, 25) $gif_control=_GUICtrlCreateGIF($gif,8,40,0) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg=$Button1 _GUICtrlStopGIF($gif_control) Case $msg=$Button2 _GUICtrlResumeGIF($gif_control) Case Else ;;;;;;; EndSelect WEnd Exit EndFunc Comments and improvements wellcome Ed ShapedGUI Creator : Shaped gui the easy way!!!Txt2au3 : the easy way to include text files into your program without fileinstall_GUICreateWithTiledBackground : Put a GIF in the background of your formsSQLite Database BrowserAnimated GIF UDF : Put animations in your GUI's Link to comment Share on other sites More sharing options...
Diana (Cda) Posted August 2, 2008 Share Posted August 2, 2008 Took me a long time, but managed to change the first bit slightly to display an animated gif in lieu of an icon and put an OK button in. I haven't yet successfully incorporated this into a script so that it works, but this is slightly different use of the example script given here that I thought might be of help to other newbies, even if to just get an idea from it <g>: Opt("MustDeclareVars", 1) #include <IE.au3> #include <GUIConstants.au3> #include <_AnimatedGIF.au3> _BoxWithAnimatedGIF() Func _BoxWithAnimatedGIF() Local $pheight = 50, $pwidth = 50, $gif, $gif_control, $Label1, $Form1, $OK_Button, $msg $gif = @ScriptDir & "\Box with animated GIF + OK button.gif" If @error Then Exit $Form1 = GUICreate("Reminder!", 180, 85, 700, 120, -1, $WS_EX_TOPMOST) ; width, height, left, top, "-1, $WS_EX_TOPMOST" makes GUI ontop $Label1 = GUICtrlCreateLabel("Don't forget ...", 60, 15, 575, 25); Left, Right, Width, Height of inside text box. $OK_Button = GUICtrlCreateButton("OK", 60, 50, 65, 25) ; left, top, width, height $gif_control=_GUICtrlCreateGIF($gif,15,15,0) ; width, height, left, top GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg=$OK_Button Exit ; finished Case Else ;;;;;;; EndSelect WEnd Exit EndFunc The animated gif shows up in the style of a flashing exclamation point icon. Link to comment Share on other sites More sharing options...
Zedna Posted August 2, 2008 Share Posted August 2, 2008 Look at Animated Gif using GDI+ http://www.autoitscript.com/forum/index.php?showtopic=77179 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted August 2, 2008 Share Posted August 2, 2008 Hi all,If the GUI is resizing (Maximized or Restored), how to do with that the gif accompanies that?Sorry for my english...Try GUICtrlSetResizing() or GUIRegisterMsg() with WM_SIZE Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted August 2, 2008 Share Posted August 2, 2008 But I don't know how to do... You could give an example?As obvious: Helpfile is your best friend :-)GUICtrlCreateObj(...)GUICtrlSetResizing (-1,$GUI_DOCKALL) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ChromeFan Posted September 7, 2008 Share Posted September 7, 2008 Thanks to "GaryFrost" for wonderful and easy to understand code/example. it's great because i was trying for a long time for it. Website: www.cerescode.comForum: www.forum.cerescode.comIRC: irc.freenode.net , Channel: #Ceres--------------------Autoit Wrappers, Great additions to your script (Must See) (By: Valuater)Read It Befor Asking Question Click Here...--------------------Join Monoceres's Forums http://www.monoceres.se--------------------There are three kinds of people: Those who make things happen, those who watch things happen, and those who ask, What happened? Casey Stengel Link to comment Share on other sites More sharing options...
Belini Posted May 8, 2012 Share Posted May 8, 2012 (edited) I want to show GIF and then delete the control to display an AVI, which command deletes the control of GIF?_GUICtrlCreateGIF() ;create an animated gif_GUICtrlStopGIF() ;stops an animation_GUICtrlResumeGIF() ;resume animation_GUICtrldeleteGIF() ;????????????????link post: Edited May 8, 2012 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now