Popular Post trancexx Posted June 3, 2009 Popular Post Posted June 3, 2009 (edited) No it doesn't speak, I lied. That is impossible.It's about setting animated GIF (and every other type of images) to a GUI control.How is this done for animated GIF? Few simple steps:- created ImageList of GIF Bitmaps retrieved from gif file/resource- created Pic control- every now and then another image is displayed. This is determined by frame delay time - see gif specification somewhere.That's it.All that takes time and could potentially block our gui/script. That's why flying assembly is used. Animation is done in another thread different from one AutoIt's code is executed in. Nothing stops animation but you.Animation works both for x64 and x86. Also it works for all kind of images not only GIFs. That means you can use it to display PNGs, BMPs, JPGs, etc... All of them from resources too.Example:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "GIFAnimation.au3" Opt("MustDeclareVars", 1) ; Start by choosing GIF to display Global $sFile = FileOpenDialog("Choose Image", "", "(*.gif;*.png;*.jpg;*.tiff;*.bmp;*.jpeg)", -1, "") If @error Then Exit ; Make GUI Global $hGui = GUICreate("GIF Animation", 500, 500, -1, -1, $WS_OVERLAPPEDWINDOW) ; Add some buttons Global $hButton = GUICtrlCreateButton("&Pause animation", 50, 450, 100, 25) Global $hButton1 = GUICtrlCreateButton("&Delete Control", 200, 450, 100, 25) Global $hButton2 = GUICtrlCreateButton("&Open Image", 350, 450, 100, 25) ; Make GIF Control Global $hGIF = _GUICtrlCreateGIF($sFile, "", 10, 10) If @extended Then GUICtrlSetState($hButton, $GUI_DISABLE) GUICtrlSetTip($hGIF, "Image") ; Additional processing of some windows messages (for example) GUIRegisterMsg(133, "_Refresh") ; WM_NCPAINT GUIRegisterMsg(15, "_ValidateGIFs") ; WM_PAINT Global $iPlay = 1 ; Show it GUISetState() ; Loop till end While 1 Switch GUIGetMsg() Case -3 Exit Case $hButton If $iPlay Then If _GIF_PauseAnimation($hGIF) Then $iPlay = 0 GUICtrlSetData($hButton, "Resume animation") EndIf Else If _GIF_ResumeAnimation($hGIF) Then $iPlay = 1 GUICtrlSetData($hButton, "Pause animation") EndIf EndIf Case $hButton1 _GIF_DeleteGIF($hGIF) Case $hButton2 $sFile = FileOpenDialog("Choose gif", "", "(*.gif;*.png;*.jpg;*.tiff;*.bmp;*.jpeg)", -1, "", $hGui) If Not @error Then _GIF_DeleteGIF($hGIF); delete previous $hGIF = _GUICtrlCreateGIF($sFile, "", 10, 10) If @extended Then GUICtrlSetState($hButton, $GUI_DISABLE) Else GUICtrlSetState($hButton, $GUI_ENABLE) EndIf GUICtrlSetTip($hGIF, "Image") $iPlay = 1 GUICtrlSetData($hButton, "Pause animation") EndIf EndSwitch WEnd Func _Refresh($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _GIF_RefreshGIF($hGIF) EndFunc ;==>_Refresh Func _ValidateGIFs($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _GIF_ValidateGIF($hGIF) EndFunc ;==>_ValidateGIFsIt should be 0% cpu.Download from here if you want to impress chicks: http://code.google.com/p/gif-animation/downloads/listThere are 8 examples in there. GIF files are downloaded automatically if some example script needs it. Mostly from photobucket.com. Some examples work without classic download. Required data is get with InetRead(). That's mighty cool.So, download, open ZIP, grab folder inside and place it where you want. Run examples and that's it.Word or two about main function, _GUICtrlCreateGIF(). It can handle all sorts of input. Will display Images that are passed as binary, resource identifiers, strings, file names, ... everything. If it's valid image all works. For example, all this is valid:; Pass GIF File path/name _GUICtrlCreateGIF("Some.gif", "", 10, 10) ; Binary data _GUICtrlCreateGIF($bGIF, "", 10, 10,) ; PE Resource (file GIF.dll, Type: GIF, Name: 4) _GUICtrlCreateGIF("GIF.dll", "GIF;4", 10, 10, 100, 120) ; PE Resource (file @AutoItExe, Type: RES, Name: BLAH, Language: 1033) _GUICtrlCreateGIF(@AutoItExe, "RES;BLAH;1033", 10, 10) ; PE Resource (file "explorer.exe", Type: 2, Name: 6801) _GUICtrlCreateGIF("explorer.exe", "2;6801", 10, 10) ;<- BITMAP ; PE Resource (file @AutoItExe, Type: RC_DATA, Name: PNG) _GUICtrlCreateGIF(@AutoItExe, "10;PNG", 10, 10) ; GIF string _GUICtrlCreateGIF(FileRead("Some.gif"), "", 10, 10)____________________________________________ Edited April 6, 2013 by trancexx Gianni, MaxG, mesale0077 and 9 others 12 ♡♡♡ . eMyvnE
froufrou Posted June 4, 2009 Posted June 4, 2009 I don"t know what i'm doing wrong,but all i can get is a flash of my .gif and then script closes.
trancexx Posted June 4, 2009 Author Posted June 4, 2009 I don"t know what i'm doing wrong,but all i can get is a flash of my .gif and then script closes.Is that for all gif files you have or just that one? If it's just that one could you upload it somewhere and post link to it. One more thing. Could you try this script. Animation there is done with bitmaps. Just start the script, go to menu and choose Action -> Initialize Compiler -> Generate Initial DLL and then drop some gif on the treeview on the left. Click on treeview pluses to get to the gif and see if you can view it on the right. (Hope it's not too confusing) I noticed that I put wrong comment in line of assembly. It should be: "B8" & SwapEndian($pSleep) & _ ; mov eax, Sleep instead of what it says now. ♡♡♡ . eMyvnE
UEZ Posted June 4, 2009 Posted June 4, 2009 Excellent work! But Stop / Resume is not working properly. My understanding is that when I press stop the animation should stop at current frame. When pressing resume it should continue playing where it has stopped! UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
ptrex Posted June 4, 2009 Posted June 4, 2009 @trancexx Great stuff !! Tested both the GIF from files as well as from binary : Binary example : GifAnimations_Form_Binary.au3 Thanks for sharing. Regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
froufrou Posted June 4, 2009 Posted June 4, 2009 Is that for all gif files you have or just that one? If it's just that one could you upload it somewhere and post link to it. One more thing. Could you try this script. Animation there is done with bitmaps. Just start the script, go to menu and choose Action -> Initialize Compiler -> Generate Initial DLL and then drop some gif on the treeview on the left. Click on treeview pluses to get to the gif and see if you can view it on the right. (Hope it's not too confusing) I noticed that I put wrong comment in line of assembly. It should be: "B8" & SwapEndian($pSleep) & _ ; mov eax, Sleep instead of what it says now. Wow! I just realized you did the resource compiler script.I have been using that,Love it.And yes i can see my GIFS in the resources preview pane.But not with this one,but i am going to keep tryin.
WideBoyDixon Posted June 4, 2009 Posted June 4, 2009 Very nice work. WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center]
trancexx Posted June 4, 2009 Author Posted June 4, 2009 Thanks guys.@UEZ, that part is working as it should only gets interrupted by processing WM_PAINT message. This is the case for not-transparent gifs because they are drawn using DrawIconEx function which is flicker free. Remove GUIRegisterMsg(15, "_Refresh") part to see it. ♡♡♡ . eMyvnE
UEZ Posted June 5, 2009 Posted June 5, 2009 Thanks guys.@UEZ, that part is working as it should only gets interrupted by processing WM_PAINT message. This is the case for not-transparent gifs because they are drawn using DrawIconEx function which is flicker free. Remove GUIRegisterMsg(15, "_Refresh") part to see it.Thanks. Now it is working as expected!UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
arcker Posted June 5, 2009 Posted June 5, 2009 finally, gif animation without block the main process. excellent work trancexx -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
trancexx Posted June 5, 2009 Author Posted June 5, 2009 finally, gif animation without block the main process.excellent work trancexx What a funny smiley.You used it in an exquisite manner. Completely out of context. Brilliant. ♡♡♡ . eMyvnE
trancexx Posted June 6, 2009 Author Posted June 6, 2009 (edited) Here's a new example. More gifs used. When you run it first time wait a bit for the download: check first post←expandcollapse popup#include <WindowsConstants.au3> #include "GIFAnimation.au3" Opt("MustDeclareVars", 1) Global $sTempFolder = @TempDir & "\GIFS" TrayTip("GIF Download", "Please wait while gifs are downloaded and processed", 0) DirCreate($sTempFolder) Global $hGui = GUICreate("GIF Animations", 670, 520);, -1, -1, $WS_OVERLAPPEDWINDOW) ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Global $sFile = $sTempFolder & "\smiley-computer012.gif" If Not FileExists($sFile) Then InetGet("http://www.freesmileys.org/smileys/smiley-computer012.gif", $sFile) EndIf Global $aGIFArrayOfIconHandles Global $hGIFThread Global $iGIFTransparent Global $tFrameCurrent Global $hGIF = _GUICtrlCreateGIF($sFile, 10, 10, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) GUICtrlSetTip($hGIF, "Hit him") ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Global $sFile1 = $sTempFolder & "\heart.gif" If Not FileExists($sFile1) Then InetGet("http://i54.photobucket.com/albums/g107/onlinegemini/heart.gif", $sFile1) EndIf Global $aGIFArrayOfIconHandles1 Global $hGIFThread1 Global $iGIFTransparent1 Global $tFrameCurrent1 Global $hGIF1 = _GUICtrlCreateGIF($sFile1, 5, 210, $aGIFArrayOfIconHandles1, $hGIFThread1, $iGIFTransparent1, $tFrameCurrent1) GUICtrlSetTip($hGIF1, "Playing hearts") ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Global $sFile2 = $sTempFolder & "\063.gif" If Not FileExists($sFile2) Then InetGet("http://i338.photobucket.com/albums/n415/glbo/flowers/063.gif", $sFile2) EndIf Global $aGIFArrayOfIconHandles2 Global $hGIFThread2 Global $iGIFTransparent2 Global $tFrameCurrent2 Global $hGIF2 = _GUICtrlCreateGIF($sFile2, 307, 10, $aGIFArrayOfIconHandles2, $hGIFThread2, $iGIFTransparent2, $tFrameCurrent2) GUICtrlSetTip($hGIF2, "Lemonade") ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Global $sFile3 = $sTempFolder & "\hekla.gif" If Not FileExists($sFile3) Then InetGet("http://i241.photobucket.com/albums/ff141/trancexx_bucket/hekla.gif", $sFile3) EndIf Global $aGIFArrayOfIconHandles3 Global $hGIFThread3 Global $iGIFTransparent3 Global $tFrameCurrent3 Global $hGIF3 = _GUICtrlCreateGIF($sFile3, 49, 80, $aGIFArrayOfIconHandles3, $hGIFThread3, $iGIFTransparent3, $tFrameCurrent3) GUICtrlSetTip($hGIF3, "What?") ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Global $sFile4 = $sTempFolder & "\36.gif" If Not FileExists($sFile4) Then InetGet("http://i241.photobucket.com/albums/ff141/trancexx_bucket/36.gif", $sFile4) EndIf Global $aGIFArrayOfIconHandles4 Global $hGIFThread4 Global $iGIFTransparent4 Global $tFrameCurrent4 Global $hGIF4 = _GUICtrlCreateGIF($sFile4, 170, 100, $aGIFArrayOfIconHandles4, $hGIFThread4, $iGIFTransparent4, $tFrameCurrent4) GUICtrlSetTip($hGIF4, "Bug") ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Global $sFile5 = $sTempFolder & "\angry.gif" If Not FileExists($sFile5) Then InetGet("http://www.sherv.net/cm/emo/hello-kitty/angry.gif", $sFile5) EndIf Global $aGIFArrayOfIconHandles5 Global $hGIFThread5 Global $iGIFTransparent5 Global $tFrameCurrent5 Global $hGIF5 = _GUICtrlCreateGIF($sFile5, 590, 470, $aGIFArrayOfIconHandles5, $hGIFThread5, $iGIFTransparent5, $tFrameCurrent5) GUICtrlSetTip($hGIF5, "Angry kitty") ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Global $sFile6 = $sTempFolder & "\marvin.gif" If Not FileExists($sFile6) Then InetGet("http://www.sherv.net/cm/emo/south-park/marvin.gif", $sFile6) EndIf Global $aGIFArrayOfIconHandles6 Global $hGIFThread6 Global $iGIFTransparent6 Global $tFrameCurrent6 Global $hGIF6 = _GUICtrlCreateGIF($sFile6, 520, 380, $aGIFArrayOfIconHandles6, $hGIFThread6, $iGIFTransparent6, $tFrameCurrent6) GUICtrlSetTip($hGIF6, "Marvin") ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Global $sFile7 = $sTempFolder & "\loading.gif" If Not FileExists($sFile7) Then InetGet("http://ostlerinc.com/contact/loading.gif", $sFile7) EndIf Global $aGIFArrayOfIconHandles7 Global $hGIFThread7 Global $iGIFTransparent7 Global $tFrameCurrent7 Global $hGIF7 = _GUICtrlCreateGIF($sFile7, 350, 350, $aGIFArrayOfIconHandles7, $hGIFThread7, $iGIFTransparent7, $tFrameCurrent7) GUICtrlSetTip($hGIF7, "loading") ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Global $sFile8 = $sTempFolder & "\loading2.gif" If Not FileExists($sFile8) Then InetGet("http://www.plosntds.org/images/loading.gif", $sFile8) EndIf Global $aGIFArrayOfIconHandles8 Global $hGIFThread8 Global $iGIFTransparent8 Global $tFrameCurrent8 Global $hGIF8 = _GUICtrlCreateGIF($sFile8, 350, 390, $aGIFArrayOfIconHandles8, $hGIFThread8, $iGIFTransparent8, $tFrameCurrent8) GUICtrlSetTip($hGIF8, "loading") ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Global $hButton = GUICtrlCreateButton("MsgBox", 370, 490, 100, 25) TrayTip("", "", 0) GUIRegisterMsg(15, "_Refresh"); WM_PAINT GUISetState() While 1 Switch GUIGetMsg() Case - 3 Exit Case $hButton MsgBox(64, "Some title", "Just to see is the gifs are blocked by this and vice versa.", 0, $hGui) EndSwitch WEnd Func _Refresh($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _RefreshGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) _RefreshGIF($hGIF1, $aGIFArrayOfIconHandles1, $hGIFThread1, $iGIFTransparent1, $tFrameCurrent1) _RefreshGIF($hGIF2, $aGIFArrayOfIconHandles2, $hGIFThread2, $iGIFTransparent2, $tFrameCurrent2) _RefreshGIF($hGIF3, $aGIFArrayOfIconHandles3, $hGIFThread3, $iGIFTransparent3, $tFrameCurrent3) _RefreshGIF($hGIF4, $aGIFArrayOfIconHandles4, $hGIFThread4, $iGIFTransparent4, $tFrameCurrent4) _RefreshGIF($hGIF5, $aGIFArrayOfIconHandles5, $hGIFThread5, $iGIFTransparent5, $tFrameCurrent5) _RefreshGIF($hGIF6, $aGIFArrayOfIconHandles6, $hGIFThread6, $iGIFTransparent6, $tFrameCurrent6) _RefreshGIF($hGIF7, $aGIFArrayOfIconHandles7, $hGIFThread7, $iGIFTransparent7, $tFrameCurrent7) _RefreshGIF($hGIF8, $aGIFArrayOfIconHandles8, $hGIFThread8, $iGIFTransparent8, $tFrameCurrent8) EndFunc ;==>_Refresh Edited August 1, 2010 by trancexx ♡♡♡ . eMyvnE
mesale0077 Posted June 6, 2009 Posted June 6, 2009 a picture,360 degrees to Rotate like panomara picture, how is it make? this nice idea you code,..,back ,stop,next button 360 to turn a picture. good works
trancexx Posted June 7, 2009 Author Posted June 7, 2009 a picture,360 degrees to Rotate like panomara picture, how is it make?this nice idea you code,..,back ,stop,next button 360 to turn a picture.good worksThanks.If I undertood you right you want to rotate the pic. You don't need this for that. Just search the forums.For example you could use FreeImage by ProgAndy or maybe GDI+ (there are examples around I'm sure). ♡♡♡ . eMyvnE
trancexx Posted June 8, 2009 Author Posted June 8, 2009 (edited) Another example. It's a classic splash: check first post←expandcollapse popupOpt("MustDeclareVars", 1) Opt("GUICloseOnESC", 1); ESC to exit ; Include GIF engine #include "GIFAnimation.au3" ; Get file Global $sTempFolder = @TempDir & "\GIFS" DirCreate($sTempFolder) Global $sFile = $sTempFolder & "\Loading....gif" If Not FileExists($sFile) Then TrayTip("GIF Download", "Please wait...", 0) InetGet("http://i241.photobucket.com/albums/ff141/trancexx_bucket/Loading.gif", $sFile) TrayTip("", "", 0) EndIf ; Create GUI Global $hGui = GUICreate("GIF Animations", @DesktopWidth, @DesktopHeight, 0, 0, 0x80000000);$WS_POPUP ; Make it white GUISetBkColor(0xFFFFFF) ; Set transparency WinSetTrans($hGui, 0, 170) ; GIF job Global $aGIFArrayOfIconHandles Global $hGIFThread Global $iGIFTransparent Global $tFrameCurrent Global $hGIF = _GUICtrlCreateGIF($sFile, (@DesktopWidth - 105) / 2, (@DesktopHeight - 70) / 2, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) ; Show GUI GUISetState() ; Loop and wait for/till exit While 1 If GUIGetMsg() = -3 Then Exit WEnd ; To clean at some point in a real situation _GUICtrlDeleteGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $tFrameCurrent) $iFrameCurrent = DllStructGetData($tFrameCurrent, 1)Will download the gif if you don't mind.I'm not deleting it afterward. It would be in your temp dir in GIFS folder of course.Exit by ESC. Edited August 1, 2010 by trancexx ♡♡♡ . eMyvnE
corgano Posted June 9, 2009 Posted June 9, 2009 Could you take the first script and make something similar to windows picture viewer? I got win 7 and the win 7 picture viewer does not work with animated gifs. it doesnt have to be fancy just a foward ans back button. 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e
corgano Posted June 9, 2009 Posted June 9, 2009 Why don't you do it?I guess I could, but how would I get the next image in the same folder as the selected gif? (makeing the arrows) 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e
wraithdu Posted June 9, 2009 Posted June 9, 2009 The help file and FileFindFirstFile / FileFindNextFile would be a good place to start.
trancexx Posted June 9, 2009 Author Posted June 9, 2009 The help file and FileFindFirstFile / FileFindNextFile would be a good place to start.I could be wrong but corgano likely meant something else.Probably option to switch to a new gif file found in the current folder in preview pane by clicking some right/left arrow.What do you think about GIFAnimation.au3? ♡♡♡ . eMyvnE
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