ฟอรั่ม PSsix

Would you like to react to this message? Create an account in a few clicks or log in to continue.

ฟอรั่มของบล็อก http://pssix.blogspot.com


2 posters

    วิธีสร้าง Animation GIF ใน AutoIt

    sak20102005
    sak20102005
    ระงับสมาชิก
    ระงับสมาชิก


    วิธีสร้าง Animation GIF ใน AutoIt Empty
    จำนวนข้อความ : 96
    ความนิยม : 4
    เข้าร่วมเมื่อ : 07/04/2011

    วิธีสร้าง Animation GIF ใน AutoIt Empty วิธีสร้าง Animation GIF ใน AutoIt

    ตั้งหัวข้อ by sak20102005 03/05/11, 01:52 am

    ทีแรกจะลง source code ให้ไปศึกษากันเอง แต่มาคิดอีกที คงจะไม่ได้สาระความรู้ซักเท่าไหร่ ถ้าไม่มีการอธิบายโค๊ด
    คนที่เก่งก็หวงวิชา หรือรู้วิธีแต่ไม่สามารถบรรยายออกมาเป็นบทความได้ หรือว่าขี้เกียจเขียนบทความ ก็สุดจะเดา
    คนที่เขียนโค๊ด AutoIt เก่งๆ ..การสร้างภาพเอนิเมชั่นด้วยการเขียนคำสั่ง Autoit ไม่ใช่เรื่องยาก เพราะเขารู้ว่าจะเขียนยังไง
    ในขั้นตอนเดียวแล้วสามารถแสดงผลภาพเมนิชั่นออกมาได้ แต่สำหรับเราๆท่านๆคงต้องพึ่งสคริ๊ป includ กันไปก่อน
    เพราะจะทำให้ไม่ต้องเขียนคำสั่งทั้งหมดแบบยาวๆ ลงสคริ๊ป includ ไว้ให้ก่อน
    คราวหน้าเรามาลองศึกษาการเขียนคำสั่ง Autoit เพื่อสร้างภาพเอนิเมชั่นกัน

    includ script: GIFAnimation.au3
    Code:

    #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
    #include-once

    Global Const $hGIFDLL__KERNEL32 = DllOpen("kernel32.dll")
    Global Const $hGIFDLL__USER32 = DllOpen("user32.dll")
    Global Const $hGIFDLL__GDI32 = DllOpen("gdi32.dll")
    Global Const $hGIFDLL__COMCTL32 = DllOpen("comctl32.dll")
    Global Const $hGIFDLL__OLE32 = DllOpen("ole32.dll")
    Global Const $hGIFDLL__GDIPLUS = DllOpen("gdiplus.dll")
    Global $sGIF__ASSOCSTRING_INTERNAL = ";"

    Func _GIF_DeleteGIF($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)
       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;", _
             $pGIF)
       Local $hGIFThread = DllStructGetData($tGIF, "GIFThread")
       If $hGIFThread Then
           _GIF_ResumeThread($hGIFThread)
          DllStructSetData($tGIF, "ExitFlag", 1)
          _GIF_WaitForSingleObject($hGIFThread)
          _GIF_CloseHandle($hGIFThread)
       EndIf
        Local $pCodeBuffer = DllStructGetData($tGIF, "CodeBuffer")
       If $pCodeBuffer Then _GIF_MemGlobalFree($pCodeBuffer)
       Local $hImageList = DllStructGetData($tGIF, "ImageList")
       If $hImageList Then _GIF_ImageList_Destroy($hImageList)
       _GIF_MemGlobalFree($pGIF)
        Local $hGIFControl = _GIF_GetDlgCtrlID(DllStructGetData($tGIF, "ControlHandle"))
       _GIF_DeleteObject(GUICtrlSendMsg($hGIFControl, 370, 0, 0))
       GUICtrlDelete($hGIFControl)
       $sGIF__ASSOCSTRING_INTERNAL = StringReplace($sGIF__ASSOCSTRING_INTERNAL, $hGIFControl & "|" & $pGIF & ";", "")
       Return 1
    EndFunc

    Func _GIF_ExitAnimation($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)
       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;" & _
             "bool Transparent;" & _
             "dword CurrentFrame;", _
             $pGIF)
       Local $hGIFThread = DllStructGetData($tGIF, "GIFThread")
       If $hGIFThread Then
          _GIF_ResumeThread($hGIFThread)
           DllStructSetData($tGIF, "ExitFlag", 1)
          _GIF_WaitForSingleObject($hGIFThread)
          _GIF_CloseHandle($hGIFThread)
          DllStructSetData($tGIF, "GIFThread", 0)
       EndIf
       Local $pCodeBuffer = DllStructGetData($tGIF, "CodeBuffer")
       If $pCodeBuffer Then _GIF_MemGlobalFree($pCodeBuffer)
       DllStructSetData($tGIF, "CodeBuffer", 0)
       Local $hImageList = DllStructGetData($tGIF, "ImageList")
       If $hImageList Then _GIF_ImageList_Destroy($hImageList)
       DllStructSetData($tGIF, "ImageList", 0)
       DllStructSetData($tGIF, "CurrentFrame", 0)
       Local $hGIFControl = _GIF_GetDlgCtrlID(DllStructGetData($tGIF, "ControlHandle"))
       GUICtrlSetState($hGIFControl, GUICtrlGetState($hGIFControl))
       Return 1
    EndFunc

    Func _GIF_GetCurrentFrame($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)
       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;" & _
             "bool Transparent;" & _
             "dword CurrentFrame;", _
             $pGIF)
       Return DllStructGetData($tGIF, "CurrentFrame")
    EndFunc

    Func _GIF_GetDimension($vGIF, $vAdditionalData = "")
       Local $aOut[2] = [0, 0]
       Local $vData
       If IsBinary($vGIF) Then
          $vData = $vGIF
       Else
          If $vAdditionalData Then
             Local $aData = StringSplit($vAdditionalData, ";", 2)
             If UBound($aData) < 3 Then ReDim $aData[3]
             $vData = _GIF_ResourceGetAsRaw($vGIF, $aData[0], $aData[1], $aData[2])
             If @error Then
                $vData = $vGIF
             Else
                If $aData[0] = 2 Then $vData = _GIF_MakeBitmapFromRT_BITMAP($vData)
             EndIf
          Else
             $vData = $vGIF
          EndIf
       EndIf
       Local $hGDIP
       Local $hMemGlobal
       Local $pBitmap, $iWidth, $iHeight
       If IsString($vData) Then
          $pBitmap = _GIF_CreateBitmapFromFile($hGDIP, $vData, $iWidth, $iHeight)
          If @error Then $pBitmap = _GIF_CreateBitmapFromBinaryImage($hGDIP, $hMemGlobal, Binary($vData), $iWidth, $iHeight)
          If @error Then
             Local $hGIFFile = FileOpen($vData)
             $vData = FileRead($hGIFFile)
             FileClose($hGIFFile)
             $pBitmap = _GIF_CreateBitmapFromBinaryImage($hGDIP, $hMemGlobal, $vData, $iWidth, $iHeight)
          EndIf
       Else
          $pBitmap = _GIF_CreateBitmapFromBinaryImage($hGDIP, $hMemGlobal, $vData, $iWidth, $iHeight)
       EndIf
       If @error Then Return SetError(1, 0, $aOut)
       _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
       $aOut[0] = $iWidth
       $aOut[1] = $iHeight
       Return $aOut
    EndFunc

    Func _GIF_GetSize($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)
       Local $aOut[2] = [0, 0]
       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;", _
             $pGIF)
       Local $hImageList = DllStructGetData($tGIF, "ImageList")
       If $hImageList Then Return _GIF_ImageList_GetIconSize($hImageList)
       Local $hControl = DllStructGetData($tGIF, "ControlHandle")
       If Not $hControl Then Return SetError(1, 0, $aOut)
       Local $aArray = WinGetPos($hControl)
       If @error Then Return SetError(1, 0, $aOut)
       $aOut[0] = $aArray[2]
       $aOut[1] = $aArray[3]
       Return $aOut
    EndFunc

    Func _GIF_PauseAnimation($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)
       Local $tGIF = DllStructCreate("handle GIFThread;", $pGIF)
       Local $hGIFThread = DllStructGetData($tGIF, "GIFThread")
       If Not $hGIFThread Then Return SetExtended(1, 1)
       If _GIF_SuspendThread($hGIFThread) Then _GIF_ResumeThread($hGIFThread)
       Return 1
    EndFunc

    Func _GIF_RefreshGIF($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)

       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;" & _
             "bool Transparent;" & _
             "dword CurrentFrame;", _
             $pGIF)
       If @error Then Return SetError(1, 0, 0)
       If Not DllStructGetData($tGIF, "ImageList") Then Return 1
       Local $hDC = _GIF_GetDC(DllStructGetData($tGIF, "ControlHandle"))
       If @error Then Return SetError(2, 0, 0)
       Local $iColorRef = -1
       If DllStructGetData($tGIF, "Transparent") Then $iColorRef = _GIF_GetUnderlyingColor(DllStructGetData($tGIF, "ControlHandle"))
       _GIF_ImageList_DrawEx(DllStructGetData($tGIF, "ImageList"), DllStructGetData($tGIF, "CurrentFrame"), $hDC, 0, 0, 0, 0, $iColorRef, -1, 0)
       _GIF_ReleaseDC(0, $hDC)
       Return 1
    EndFunc

    Func _GIF_ResumeAnimation($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)
       Local $tGIF = DllStructCreate("handle GIFThread;", $pGIF)
        Local $hGIFThread = DllStructGetData($tGIF, "GIFThread")
       If Not $hGIFThread Then Return SetExtended(1, 1)
       If _GIF_ResumeThread($hGIFThread) = 2 Then _GIF_SuspendThread($hGIFThread)
       Return 1
    EndFunc

    Func _GIF_ValidateGIF($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)
       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;" & _
             "bool Transparent;" & _
             "dword CurrentFrame;" & _
             "dword NumberOfFrames;", _
             $pGIF)
       If @error Then Return SetError(1, 0, 0)
       If DllStructGetData($tGIF, "NumberOfFrames") < 2 Then Return 1
       If Not DllStructGetData($tGIF, "GIFThread") Then Return 1
       _GIF_RedrawWindow(DllStructGetData($tGIF, "ControlHandle"), 0, 0, 1280)
       _GIF_RefreshGIF($pGIF)
       Return 1
    EndFunc

    Func _GUICtrlCreateGIF($vGIF, $vAdditionalData, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iRenderingStyle = Default, $iForcedARGB = Default)
       If $iWidth = -1 Then $iWidth = Default
       If $iHeight = -1 Then $iHeight = Default
       Local $vData
       If IsBinary($vGIF) Then
          $vData = $vGIF
       Else
          If $vAdditionalData Then
             Local $aData = StringSplit($vAdditionalData, ";", 2)
             If UBound($aData) < 3 Then ReDim $aData[3]
             $vData = _GIF_ResourceGetAsRaw($vGIF, $aData[0], $aData[1], $aData[2])
             If @error Then
                $vData = $vGIF
             Else
                If $aData[0] = 2 Then $vData = _GIF_MakeBitmapFromRT_BITMAP($vData)
             EndIf
          Else
             $vData = $vGIF
          EndIf
       EndIf
       Local $hGIFControl, $iWidthDef, $iHeightDef
       If Not IsKeyword($iWidthDef) Then $iWidthDef = $iWidth
       If Not IsKeyword($iHeightDef) Then $iHeightDef = $iHeight
       Local $pGIF = _GIF_Create_pGIF($vData, $iWidthDef, $iHeightDef, $hGIFControl, $iLeft, $iTop, $iForcedARGB)
       If @error Then
          Local $hGIFFile = FileOpen($vData)
          $vData = FileRead($hGIFFile)
          FileClose($hGIFFile)
          $pGIF = _GIF_Create_pGIF($vData, $iWidthDef, $iHeightDef, $hGIFControl, $iLeft, $iTop, $iForcedARGB)
          If @error Then
             $pGIF = _GIF_Create_pGIF(Binary($vGIF), $iWidthDef, $iHeightDef, $hGIFControl, $iLeft, $iTop, $iForcedARGB)
             If @error Then Return SetError(1, @extended = True, 0)
          EndIf
       EndIf
       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;" & _
             "bool Transparent;" & _
             "dword CurrentFrame;" & _
             "dword NumberOfFrames;", _
             $pGIF)
       Local $iFrameCount = DllStructGetData($tGIF, "NumberOfFrames")
       $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;" & _
             "bool Transparent;" & _
             "dword CurrentFrame;" & _
             "dword NumberOfFrames;" & _
             "dword FrameDelay[" & $iFrameCount & "];", _
             $pGIF)
       GUICtrlSetResizing($hGIFControl, 802)
       DllStructSetData($tGIF, "ControlHandle", GUICtrlGetHandle($hGIFControl))
       If $iFrameCount = 1 Then
          $sGIF__ASSOCSTRING_INTERNAL &= $hGIFControl & "|" & $pGIF & ";"
          Return SetExtended(1, $hGIFControl)
       EndIf
       Local $iSizeCodeBuffer = 181
       If @AutoItX64 Then $iSizeCodeBuffer = 274
       Local $pCodeBuffer = _GIF_MemGlobalAlloc($iSizeCodeBuffer, 64)
       If @error Then Return SetError(2, 0, $hGIFControl)
       DllStructSetData($tGIF, "CodeBuffer", $pCodeBuffer)
       _GIF_VirtualProtect($pCodeBuffer, $iSizeCodeBuffer, 64)
       If @error Then Return SetError(3, 0, $hGIFControl)
       Local $tCodeBuffer = DllStructCreate("byte[" & $iSizeCodeBuffer & "]", $pCodeBuffer)
       Local $pImageList_DrawEx = _GIF_GetAddress(_GIF_GetModuleHandle("comctl32.dll"), "ImageList_DrawEx")
       If @error Then Return SetError(4, 1, $hGIFControl)
       Local $pSleep = _GIF_GetAddress(_GIF_GetModuleHandle("kernel32.dll"), "Sleep")
       If @error Then Return SetError(4, 2, $hGIFControl)
       Local $pGetPixel = _GIF_GetAddress(_GIF_GetModuleHandle("gdi32.dll"), "GetPixel")
       If @error Then Return SetError(4, 3, $hGIFControl)
       Local $hUser32 = _GIF_GetModuleHandle("user32.dll")
       Local $pGetDC = _GIF_GetAddress($hUser32, "GetDC")
       If @error Then Return SetError(4, 4, $hGIFControl)
       Local $pReleaseDC = _GIF_GetAddress($hUser32, "ReleaseDC")
       If @error Then Return SetError(4, 5, $hGIFControl)
       Local $pGetParent = _GIF_GetAddress($hUser32, "GetParent")
       If @error Then Return SetError(4, 6, $hGIFControl)
        Local $hImageList = DllStructGetData($tGIF, "ImageList")
       Local $hControl = DllStructGetData($tGIF, "ControlHandle")
       Local $iStyle
       If $iRenderingStyle = Default Then
          $iStyle = 1
          If DllStructGetData($tGIF, "Transparent") Then $iStyle = 0
       Else
          $iStyle = $iRenderingStyle
       EndIf
       If @AutoItX64 Then
          DllStructSetData($tCodeBuffer, 1, _
                "0x" & _
                "4883EC" & _GIF_SwapEndian(88, 1) & _
                "" & _
                "4831F6" & _
                "" & _
                "" & _
                "8BC6" & _
                "A3" & _GIF_SwapEndian(DllStructGetPtr($tGIF, "CurrentFrame"), 8) & _
                "" & _
                "48B9" & _GIF_SwapEndian($hControl, 8) & _
                "48B8" & _GIF_SwapEndian($pGetParent, 8) & _
                "FFD0" & _
                "" & _
                "4889C1" & _
                "48B8" & _GIF_SwapEndian($pGetDC, 8) & _
                "FFD0" & _
                "" & _
                "4889C3" & _
                "" & _
                "49C7C0" & _GIF_SwapEndian($iTop, 4) & _
                "BA" & _GIF_SwapEndian($iLeft, 4) & _
                "4889C1" & _
                "48B8" & _GIF_SwapEndian($pGetPixel, 8) & _
                "FFD0" & _
                "89442438" & _
                "" & _
                "4889DA" & _
                "48B9" & _GIF_SwapEndian(0, 8) & _
                "48B8" & _GIF_SwapEndian($pReleaseDC, 8) & _
                "FFD0" & _
                "89442448" & _
                "" & _
                "48B9" & _GIF_SwapEndian($hControl, 8) & _
                "48B8" & _GIF_SwapEndian($pGetDC, 8) & _
                "FFD0" & _
                "" & _
                "4889C3" & _
                "4989C0" & _
                "49C7C1" & _GIF_SwapEndian(0, 4) & _
                "89F2" & _
                "48B9" & _GIF_SwapEndian($hImageList, 8) & _
                "" & _
                "48B8" & _GIF_SwapEndian($pImageList_DrawEx, 8) & _
                "FFD0" & _
                "" & _
                "4889DA" & _
                "48B9" & _GIF_SwapEndian(0, 8) & _
                "48B8" & _GIF_SwapEndian($pReleaseDC, 8) & _
                "FFD0" & _
                "" & _
                "A1" & _GIF_SwapEndian(DllStructGetPtr($tGIF, "ExitFlag"), 8) & _
                "85C0" & _
                "75" & _GIF_SwapEndian(46, 1) & _
                "" & _
                "48BB" & _GIF_SwapEndian(DllStructGetPtr($tGIF, "FrameDelay"), 8) & _
                "488B0CB3" & _
                "48B8" & _GIF_SwapEndian($pSleep, 8) & _
                "FFD0" & _
                "" & _
                "FFC6" & _
                "" & _
                "81FE" & _GIF_SwapEndian($iFrameCount, 4) & _
                "" & _
                "74" & _GIF_SwapEndian(5, 1) & _
                "E9" & _GIF_SwapEndian(-254, 4) & _
                "E9" & _GIF_SwapEndian(-262, 4) & _
                "" & _
                "4831C0" & _
                "4883C4" & _GIF_SwapEndian(88, 1) & _
                "C3" _
                )
       Else
          DllStructSetData($tCodeBuffer, 1, _
                "0x" & _
                "" & _
                "33F6" & _
                "" & _
                "" & _
                "8BC6" & _
                "A3" & _GIF_SwapEndian(DllStructGetPtr($tGIF, "CurrentFrame"), 4) & _
                "68" & _GIF_SwapEndian($iStyle, 4) & _
                "68" & _GIF_SwapEndian(-1, 4) & _
                "" & _
                "68" & _GIF_SwapEndian($hControl, 4) & _
                "B8" & _GIF_SwapEndian($pGetParent, 4) & _
                "FFD0" & _
                "" & _
                "50" & _
                "B8" & _GIF_SwapEndian($pGetDC, 4) & _
                "FFD0" & _
                "" & _
                "8BD8" & _
                "68" & _GIF_SwapEndian($iTop, 4) & _
                "68" & _GIF_SwapEndian($iLeft, 4) & _
                "" & _
                "53" & _
                "B8" & _GIF_SwapEndian($pGetPixel, 4) & _
                "FFD0" & _
                "50" & _
                "" & _
                "53" & _
                "68" & _GIF_SwapEndian(0, 4) & _
                "B8" & _GIF_SwapEndian($pReleaseDC, 4) & _
                "FFD0" & _
                "68" & _GIF_SwapEndian(0, 4) & _
                "68" & _GIF_SwapEndian(0, 4) & _
                "68" & _GIF_SwapEndian(0, 4) & _
                "68" & _GIF_SwapEndian(0, 4) & _
                "" & _
                "68" & _GIF_SwapEndian($hControl, 4) & _
                "B8" & _GIF_SwapEndian($pGetDC, 4) & _
                "FFD0" & _
                "" & _
                "8BD8" & _
                "50" & _
                "56" & _
                "68" & _GIF_SwapEndian($hImageList, 4) & _
                "" & _
                "B8" & _GIF_SwapEndian($pImageList_DrawEx, 4) & _
                "FFD0" & _
                "" & _
                "53" & _
                "68" & _GIF_SwapEndian(0, 4) & _
                "B8" & _GIF_SwapEndian($pReleaseDC, 4) & _
                "FFD0" & _
                "" & _
                "A1" & _GIF_SwapEndian(DllStructGetPtr($tGIF, "ExitFlag"), 4) & _
                "85C0" & _
                "75" & _GIF_SwapEndian(35, 1) & _
                "" & _
                "BB" & _GIF_SwapEndian(DllStructGetPtr($tGIF, "FrameDelay"), 4) & _
                "8B0CB3" & _
                "51" & _
                "B8" & _GIF_SwapEndian($pSleep, 4) & _
                "FFD0" & _
                "" & _
                "46" & _
                "" & _
                "81FE" & _GIF_SwapEndian($iFrameCount, 4) & _
                "" & _
                "74" & _GIF_SwapEndian(5, 1) & _
                "E9" & _GIF_SwapEndian(-171, 4) & _
                "E9" & _GIF_SwapEndian(-178, 4) & _
                "" & _
                "33C0" & _
                "C3" _
                )
       EndIf
       Local $hThread = _GIF_CreateThread($pCodeBuffer)
       If @error Then Return SetError(5, 0, $hGIFControl)
       DllStructSetData($tGIF, "GIFThread", $hThread)
       _GIF_InvalidateRect(_GIF_GetParent($hControl))
       $sGIF__ASSOCSTRING_INTERNAL &= $hGIFControl & "|" & $pGIF & ";"
       Return $hGIFControl
    EndFunc

    Func _GIF_CloseHandle($hHandle)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "bool", "CloseHandle", "handle", $hHandle)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_WaitForSingleObject($hHandle, $iMiliSec = -1)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "dword", "WaitForSingleObject", "handle", $hHandle, "dword", $iMiliSec)
       If @error Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_CreateThread($pAddress)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "handle", "CreateThread", _
             "ptr", 0, _
             "dword_ptr", 0, _
             "ptr", $pAddress, _
             "ptr", 0, _
             "dword", 0, _
             "dword*", 0)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_SuspendThread($hTread)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "dword", "SuspendThread", "handle", $hTread)
       If @error Or $aCall[0] = -1 Then Return SetError(1, 0, -1)
       Return $aCall[0]
    EndFunc

    Func _GIF_ResumeThread($hTread)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "dword", "ResumeThread", "handle", $hTread)
       If @error Or $aCall[0] = -1 Then Return SetError(1, 0, -1)
       Return $aCall[0]
    EndFunc

    Func _GIF_VirtualProtect($pAddress, $iSize, $iProtection)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "bool", "VirtualProtect", "ptr", $pAddress, "dword_ptr", $iSize, "dword", $iProtection, "dword*", 0)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GetAddress($hModule, $vFuncName)
       Local $sType = "str"
       If IsNumber($vFuncName) Then $sType = "int"
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "ptr", "GetProcAddress", "handle", $hModule, $sType, $vFuncName)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_GetModuleHandle($vModule = 0)
       Local $sType = "wstr"
       If Not $vModule Then $sType = "ptr"
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "ptr", "GetModuleHandleW", $sType, $vModule)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_GetBkColor($hWnd)
       Local $hDC = _GIF_GetDC($hWnd)
       If @error Then Return SetError(1, 0, -1)
       Local $aCall = DllCall($hGIFDLL__GDI32, "dword", "GetBkColor", "handle", $hDC)
       If @error Or $aCall[0] = -1 Then
          _GIF_ReleaseDC($hWnd, $hDC)
          Return SetError(2, 0, -1)
       EndIf
       _GIF_ReleaseDC($hWnd, $hDC)
       Return $aCall[0]
    EndFunc

    Func _GIF_GetDC($hWnd)
       Local $aCall = DllCall($hGIFDLL__USER32, "handle", "GetDC", "hwnd", $hWnd)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_ReleaseDC($hWnd, $hDC)
       Local $aCall = DllCall($hGIFDLL__USER32, "int", "ReleaseDC", "hwnd", $hWnd, "handle", $hDC)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GetDlgCtrlID($hWnd)
       Local $aCall = DllCall($hGIFDLL__USER32, "int", "GetDlgCtrlID", "hwnd", $hWnd)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_InvalidateRect($hWnd, $pRect = 0, $fErase = True)
       Local $aCall = DllCall($hGIFDLL__USER32, "bool", "InvalidateRect", _
             "hwnd", $hWnd, _
             "ptr", $pRect, _
             "bool", $fErase)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_ValidateRect($hWnd, $pRect = 0)
       Local $aCall = DllCall($hGIFDLL__USER32, "bool", "ValidateRect", "hwnd", $hWnd, "ptr", $pRect)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_RedrawWindow($hWnd, $pRect, $hRegion, $iFlags)
       Local $aCall = DllCall($hGIFDLL__USER32, "bool", "RedrawWindow", "hwnd", $hWnd, "ptr", $pRect, "handle", $hRegion, "dword", $iFlags)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_GetUnderlyingColor($hWnd)
       Local $hParent = _GIF_GetParent($hWnd)
       If @error Then Return SetError(1, 0, -1)
       Local $iColor = _GIF_GetBkColor($hParent)
       Return SetError(@error, 0, $iColor)
    EndFunc

    Func _GIF_GetParent($hWnd)
       Local $aCall = DllCall($hGIFDLL__USER32, "hwnd", "GetParent", "hwnd", $hWnd)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_Create_pGIF($bBinary, ByRef $iWidth, ByRef $iHeight, ByRef $hGIFControl, $iLeft = 0, $iTop = 0, $iARGB = 0xFF000000)
       If $iARGB = Default Then $iARGB = 0xFF000000
       Local $hGDIP
       Local $hMemGlobal
       Local $pBitmap, $iWidthReal, $iHeightReal
       If IsBinary($bBinary) Then
          $pBitmap = _GIF_CreateBitmapFromBinaryImage($hGDIP, $hMemGlobal, $bBinary, $iWidthReal, $iHeightReal)
       Else
          $pBitmap = _GIF_CreateBitmapFromFile($hGDIP, $bBinary, $iWidthReal, $iHeightReal)
       EndIf
       If @error Then
          Local $iErr = @error
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
          Return SetError(1, $iErr, 0)
       EndIf
       Local $fDoResize
       If $iWidth = Default Then
          $iWidth = $iWidthReal
       Else
          $fDoResize = True
       EndIf
       If $iHeight = Default Then
          $iHeight = $iHeightReal
       Else
          $fDoResize = True
       EndIf
       Local $iFrameDimensionsCount = _GIF_GdipImageGetFrameDimensionsCount($pBitmap)
       If @error Then
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
          Return SetError(2, 0, 0)
       EndIf
       Local $tGUID = DllStructCreate("dword;word;word;byte[8]")
       Local $pGUID = DllStructGetPtr($tGUID)
       _GIF_GdipImageGetFrameDimensionsList($pBitmap, $pGUID, $iFrameDimensionsCount)
       If @error Then
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
          Return SetError(3, 0, 0)
       EndIf
       Local $iFrameCount = _GIF_GdipImageGetFrameCount($pBitmap, $pGUID)
       If @error Then
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
          Return SetError(4, 0, 0)
       EndIf
       Local $pGIF = _GIF_MemGlobalAlloc(4 * (8 + 4 * @AutoItX64 + $iFrameCount), 64)
       If @error Then
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
          Return SetError(3, 0, 0)
       EndIf
       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;" & _
             "bool Transparent;" & _
             "dword CurrentFrame;" & _
             "dword NumberOfFrames;" & _
             "dword FrameDelay[" & $iFrameCount & "];", _
             $pGIF)
       DllStructSetData($tGIF, "GIFThread", 0)
       DllStructSetData($tGIF, "ControlHandle", 0)
       DllStructSetData($tGIF, "ExitFlag", 0)
       DllStructSetData($tGIF, "CurrentFrame", 0)
       DllStructSetData($tGIF, "NumberOfFrames", $iFrameCount)
        $hGIFControl = GUICtrlCreatePic("", $iLeft, $iTop, $iWidth, $iHeight)
       If $iFrameCount = 1 Then
          Local $hGIFBitmap = _GIF_GdipCreateHBITMAPFromBitmap($pBitmap, $iARGB)
          If $fDoResize Then _GIF_ResizeBitmap($hGIFBitmap, $iWidth, $iHeight)
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
          _GIF_DeleteObject(GUICtrlSendMsg($hGIFControl, 370, 0, $hGIFBitmap))
          _GIF_DeleteObject($hGIFBitmap)
          Return $pGIF
       EndIf
        Local $hImageList = _GIF_ImageList_Create($iWidth, $iHeight, 32, $iFrameCount)
       If @error Then
          GUICtrlDelete($hGIFControl)
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal, $pGIF)
          Return SetError(4, 0, 0)
       EndIf
       DllStructSetData($tGIF, "ImageList", $hImageList)
       Local $hBitmap
       For $j = 0 To $iFrameCount - 1
          _GIF_GdipImageSelectActiveFrame($pBitmap, $pGUID, $j)
          If @error Then ContinueLoop
          $hBitmap = _GIF_GdipCreateHBITMAPFromBitmap($pBitmap, $iARGB)
          If $fDoResize Then _GIF_ResizeBitmap($hBitmap, $iWidth, $iHeight)
               _GIF_ImageList_Add($hImageList, $hBitmap)
          If $j = 0 Then
             _GIF_DeleteObject(GUICtrlSendMsg($hGIFControl, 370, 0, $hBitmap))
             _GIF_DeleteObject($hBitmap)
          EndIf
          _GIF_DeleteObject($hBitmap)
       Next
       Local $iPropertyItemSize = _GIF_GdipGetPropertyItemSize($pBitmap, 0x5100)
       If @error Then
          GUICtrlDelete($hGIFControl)
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal, $pGIF)
          Return SetError(5, 0, 0)
       EndIf
       Local $tRawPropItem = DllStructCreate("byte[" & $iPropertyItemSize & "]")
       _GIF_GdipGetPropertyItem($pBitmap, 0x5100, $iPropertyItemSize, DllStructGetPtr($tRawPropItem))
       If @error Then
          GUICtrlDelete($hGIFControl)
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal, $pGIF)
          Return SetError(6, 0, 0)
       EndIf
       Local $tPropItem = DllStructCreate("int Id;" & _
             "dword Length;" & _
             "word Type;" & _
             "ptr Value", _
             DllStructGetPtr($tRawPropItem))
        Local $iSize = DllStructGetData($tPropItem, "Length") / 4
       Local $tPropertyData = DllStructCreate("dword[" & $iSize & "]", DllStructGetData($tPropItem, "Value"))
       Local $iDelay
       For $j = 1 To $iFrameCount
          $iDelay = DllStructGetData($tPropertyData, 1, $j) * 10
          If Not $iDelay Then $iDelay = 130
          If $iDelay < 50 Then $iDelay = 50
          DllStructSetData($tGIF, "FrameDelay", $iDelay, $j)
       Next
       Local $fTransparent = True
       Local $iPixelColor = _GIF_GdipBitmapGetPixel($pBitmap, 0, 0)
       If BitShift($iPixelColor, 24) Then $fTransparent = False
       DllStructSetData($tGIF, "Transparent", $fTransparent)
       _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
       Return $pGIF
    EndFunc

    Func _GIF_CreateStreamOnHGlobal($hGlobal, $iFlag = 1)
       Local $aCall = DllCall($hGIFDLL__OLE32, "long", "CreateStreamOnHGlobal", "handle", $hGlobal, "int", $iFlag, "ptr*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[3]
    EndFunc

    Func _GIF_GetObject($hObject, $iSize, $pObject)
       Local $aCall = DllCall($hGIFDLL__GDI32, "int", "GetObject", "handle", $hObject, "int", $iSize, "ptr", $pObject)
       If @error Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_DeleteObject($hObject)
       Local $aCall = DllCall($hGIFDLL__GDI32, "bool", "DeleteObject", "handle", $hObject)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_ImageList_GetIconSize($hImageList)
       Local $aOut[2] = [0, 0]
       Local $aCall = DllCall($hGIFDLL__COMCTL32, "bool", "ImageList_GetIconSize", "handle", $hImageList, "int*", 0, "int*", 0)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, $aOut)
       $aOut[0] = $aCall[2]
       $aOut[1] = $aCall[3]
       Return $aOut
    EndFunc

    Func _GIF_ImageList_Create($iWidth, $iHeight, $iFlag, $iInitial, $iGrow = 0)
       Local $aCall = DllCall($hGIFDLL__COMCTL32, "handle", "ImageList_Create", _
             "int", $iWidth, _
             "int", $iHeight, _
             "dword", $iFlag, _
             "int", $iInitial, _
             "int", $iGrow)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_ImageList_Add($hImageList, $hBitmap)
       Local $aCall = DllCall($hGIFDLL__COMCTL32, "int", "ImageList_Add", _
             "handle", $hImageList, _
             "handle", $hBitmap, _
             "handle", 0)
       If @error Or $aCall[0] = -1 Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_ImageList_Destroy($hImageList)
       Local $aCall = DllCall($hGIFDLL__COMCTL32, "bool", "ImageList_Destroy", "handle", $hImageList)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_ImageList_DrawEx($hImageList, $iImageIndex, $hDC, $iXPos = 0, $iYPos = 0, $iWidth = 0, $iHeight = 0, $iBkColRef = -1, $iFgColRef = -1, $iStyle = 0)
       Local $aCall = DllCall($hGIFDLL__COMCTL32, "bool", "ImageList_DrawEx", _
             "handle", $hImageList, _
             "int", $iImageIndex, _
             "handle", $hDC, _
             "int", $iXPos, _
             "int", $iYPos, _
             "int", $iWidth, _
             "int", $iHeight, _
             "dword", $iBkColRef, _
             "dword", $iFgColRef, _
             "dword", $iStyle)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_CreateBitmapFromFile(ByRef $hGDIP, $sFile, ByRef $iWidth, ByRef $iHeight)
       $hGDIP = _GIF_GdiplusStartup()
       If @error Then Return SetError(1, 0, 0)
       Local $pBitmap = _GIF_GdipLoadImageFromFile($sFile)
       If @error Then
          _GIF_GdiplusShutdown($hGDIP)
          Return SetError(2, 0, 0)
       EndIf
       _GIF_GdipGetImageDimension($pBitmap, $iWidth, $iHeight)
       If @error Then
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP)
          Return SetError(3, 0, 0)
       EndIf
       Return $pBitmap
    EndFunc

    Func _GIF_CreateBitmapFromBinaryImage(ByRef $hGDIP, ByRef $hMemGlobal, $bBinary, ByRef $iWidth, ByRef $iHeight)
       Local $iSize = BinaryLen($bBinary)
       $hMemGlobal = _GIF_MemGlobalAlloc($iSize, 2)
       If @error Then Return SetError(1, 0, 0)
       Local $pMemory = _GIF_MemGlobalLock($hMemGlobal)
       If @error Then
          _GIF_MemGlobalFree($hMemGlobal)
          Return SetError(2, 0, 0)
       EndIf
       Local $tBinary = DllStructCreate("byte[" & $iSize & "]", $pMemory)
       DllStructSetData($tBinary, 1, $bBinary)
       Local $pStream = _GIF_CreateStreamOnHGlobal($pMemory)
       If @error Then
          _GIF_MemGlobalFree($hMemGlobal)
          Return SetError(3, 0, 0)
       EndIf
       _GIF_MemGlobalUnlock($pMemory)
        $hGDIP = _GIF_GdiplusStartup()
       If @error Then
          _GIF_MemGlobalFree($hMemGlobal)
          Return SetError(4, 0, 0)
       EndIf
       Local $pBitmap = _GIF_GdipCreateBitmapFromStream($pStream)
       If @error Then
          _GIF_GdiplusShutdown($hGDIP)
          _GIF_MemGlobalFree($hMemGlobal)
          Return SetError(5, 0, 0)
       EndIf
       _GIF_GdipGetImageDimension($pBitmap, $iWidth, $iHeight)
       If @error Then
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
          Return SetError(6, 0, 0)
       EndIf
       Return $pBitmap
    EndFunc

    Func _GIF_ResizeBitmap(ByRef $hBitmap, $iNewWidth, $iNewHeight)
       Local $tBMP = DllStructCreate("long Type;long Width;long Height;long WidthBytes;word Planes;word BitsPixel;ptr Bits;")
       _GIF_GetObject($hBitmap, DllStructGetSize($tBMP), DllStructGetPtr($tBMP))
       Local $pBitmap = _GIF_GdipCreateBitmapFromScan0(DllStructGetData($tBMP, "Width"), DllStructGetData($tBMP, "Height"), DllStructGetData($tBMP, "WidthBytes"), 0x26200A, DllStructGetData($tBMP, "Bits"))
       _GIF_GdipImageRotateFlip($pBitmap, 6)
       Local $pNewBitmap = _GIF_GdipCreateBitmapFromScan0($iNewWidth, $iNewHeight)
       Local $hGraphics = _GIF_GdipGetImageGraphicsContext($pNewBitmap)
       _GIF_GdipDrawImageRect($hGraphics, $pBitmap, 0, 0, $iNewWidth, $iNewHeight)
       Local $hNewBitmap = _GIF_GdipCreateHBITMAPFromBitmap($pNewBitmap)
       _GIF_GdipDisposeImage($pBitmap)
       _GIF_GdipDeleteGraphics($hGraphics)
       _GIF_DeleteObject($hBitmap)
       _GIF_GdipDisposeImage($pNewBitmap)
        $hBitmap = $hNewBitmap
       Return 1
    EndFunc

    Func _GIF_GdiplusStartup()
       Local $tGdiplusStartupInput = DllStructCreate("dword GdiplusVersion;" & _
             "ptr DebugEventCallback;" & _
             "int SuppressBackgroundThread;" & _
             "int SuppressExternalCodecs")
       DllStructSetData($tGdiplusStartupInput, "GdiplusVersion", 1)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdiplusStartup", "dword_ptr*", 0, "ptr", DllStructGetPtr($tGdiplusStartupInput), "ptr", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[1]
    EndFunc

    Func _GIF_GdiplusShutdown($hGDIP)
       DllCall($hGIFDLL__GDIPLUS, "none", "GdiplusShutdown", "dword_ptr", $hGDIP)
    EndFunc

    Func _GIF_GdipDisposeImage($hImage)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipDisposeImage", "handle", $hImage)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GdipGetImageDimension($pBitmap, ByRef $iWidth, ByRef $iHeight)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipGetImageDimension", "ptr", $pBitmap, "float*", 0, "float*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       $iWidth = $aCall[2]
       $iHeight = $aCall[3]
    EndFunc

    Func _GIF_GdipImageGetFrameDimensionsCount($pBitmap)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipImageGetFrameDimensionsCount", "ptr", $pBitmap, "dword*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[2]
    EndFunc

    Func _GIF_GdipImageGetFrameDimensionsList($pBitmap, $pGUID, $iFrameDimensionsCount)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipImageGetFrameDimensionsList", _
             "ptr", $pBitmap, _
             "ptr", $pGUID, _
             "dword", $iFrameDimensionsCount)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GdipImageGetFrameCount($pBitmap, $pGUID)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipImageGetFrameCount", _
             "ptr", $pBitmap, _
             "ptr", $pGUID, _
             "dword*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[3]
    EndFunc

    Func _GIF_GdipImageSelectActiveFrame($pBitmap, $pGUID, $iFrameIndex)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipImageSelectActiveFrame", _
             "ptr", $pBitmap, _
             "ptr", $pGUID, _
             "dword", $iFrameIndex)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GdipGetPropertyItemSize($pBitmap, $iPropID)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipGetPropertyItemSize", _
             "ptr", $pBitmap, _
             "ptr", $iPropID, _
             "dword*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[3]
    EndFunc

    Func _GIF_GdipGetPropertyItem($pBitmap, $iPropID, $iSize, $pBuffer)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipGetPropertyItem", _
             "ptr", $pBitmap, _
             "dword", $iPropID, _
             "dword", $iSize, _
             "ptr", $pBuffer)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GdipBitmapGetPixel($pBitmap, $iX, $iY)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipBitmapGetPixel", _
             "ptr", $pBitmap, _
             "int", $iX, _
             "int", $iY, _
             "dword*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[4]
    EndFunc

    Func _GIF_GdipLoadImageFromFile($sFile)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipLoadImageFromFile", "wstr", $sFile, "ptr*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[2]
    EndFunc

    Func _GIF_GdipCreateBitmapFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x26200A, $pScan0 = 0)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "dword", $iPixelFormat, "ptr", $pScan0, "ptr*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[6]
    EndFunc

    Func _GIF_GdipCreateBitmapFromStream($pStream)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipCreateBitmapFromStream", "ptr", $pStream, "ptr*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[2]
    EndFunc

    Func _GIF_GdipCreateHBITMAPFromBitmap($pBitmap, $iARGB = 0xFF000000)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipCreateHBITMAPFromBitmap", "ptr", $pBitmap, "handle*", 0, "dword", $iARGB)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[2]
    EndFunc

    Func _GIF_GdipGetImageGraphicsContext($hImage)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipGetImageGraphicsContext", "ptr", $hImage, "ptr*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[2]
    EndFunc

    Func _GIF_GdipDrawImageRect($hGraphics, $hImage, $iX, $iY, $iWidth, $iHeight)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipDrawImageRectI", "ptr", $hGraphics, "ptr", $hImage, "int", $iX, "int", $iY, "int", $iWidth, "int", $iHeight)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GdipDeleteGraphics($hGraphics)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipDeleteGraphics", "handle", $hGraphics)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GdipImageRotateFlip($hImage, $iType)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipImageRotateFlip", "handle", $hImage, "dword", $iType)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_FreeGdipAndMem($pBitmap = 0, $hGDIP = 0, $hMem = 0, $pGIF = 0)
       If $pBitmap Then _GIF_GdipDisposeImage($pBitmap)
       If $hGDIP Then _GIF_GdiplusShutdown($hGDIP)
       If $hMem Then _GIF_MemGlobalFree($hMem)
       If $pGIF Then _GIF_MemGlobalFree($pGIF)
    EndFunc

    Func _GIF_MemGlobalAlloc($iSize, $iFlag)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "handle", "GlobalAlloc", "dword", $iFlag, "dword_ptr", $iSize)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_MemGlobalFree($hMem)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "ptr", "GlobalFree", "handle", $hMem)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_MemGlobalLock($hMem)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "ptr", "GlobalLock", "handle", $hMem)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_MemGlobalUnlock($hMem)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "bool", "GlobalUnlock", "handle", $hMem)
       If @error Then Return SetError(1, 0, 0)
       If $aCall[0] Or _GIF_GetLastError() Then Return $aCall[0]
       Return 1
    EndFunc

    Func _GIF_GetLastError()
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "dword", "GetLastError")
       If @error Then Return SetError(1, 0, -1)
       Return $aCall[0]
    EndFunc

    Func _GIF_FindResourceEx($hModule, $vResType, $vResName, $iResLang = 0)
       Local $sTypeType = "wstr"
       If $vResType == Number($vResType) Then $sTypeType = "int"
       Local $sNameType = "wstr"
       If $vResName == Number($vResName) Then $sNameType = "int"
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "handle", "FindResourceExW", _
             "handle", $hModule, _
             $sTypeType, $vResType, _
             $sNameType, $vResName, _
             "int", $iResLang)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_SizeofResource($hModule, $hResource)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "int", "SizeofResource", "handle", $hModule, "handle", $hResource)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_LoadResource($hModule, $hResource)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "handle", "LoadResource", "handle", $hModule, "handle", $hResource)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_LockResource($hResource)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "ptr", "LockResource", "handle", $hResource)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_LoadLibraryEx($sModule, $iFlag = 0)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "handle", "LoadLibraryExW", "wstr", $sModule, "handle", 0, "dword", $iFlag)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_FreeLibrary($hModule)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "bool", "FreeLibrary", "handle", $hModule)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_ResourceGetAsRaw($sModule, $vResType, $vResName, $iResLang = 0)
       Local $hModule = _GIF_LoadLibraryEx($sModule, 2)
       If @error Then Return SetError(1, 0, "")
       Local $hResource = _GIF_FindResourceEx($hModule, $vResType, $vResName, $iResLang)
       If @error Then
          _GIF_FreeLibrary($hModule)
          Return SetError(2, 0, "")
       EndIf
       Local $iSizeOfResource = _GIF_SizeofResource($hModule, $hResource)
       If @error Then
          _GIF_FreeLibrary($hModule)
          Return SetError(3, 0, "")
       EndIf
       $hResource = _GIF_LoadResource($hModule, $hResource)
       If @error Then
          _GIF_FreeLibrary($hModule)
          Return SetError(4, 0, "")
       EndIf
       Local $pResource = _GIF_LockResource($hResource)
       If @error Then
          _GIF_FreeLibrary($hModule)
          Return SetError(5, 0, "")
       EndIf
       Local $tBinary = DllStructCreate("byte[" & $iSizeOfResource & "]", $pResource)
       Local $bBinary = DllStructGetData($tBinary, 1)
       _GIF_FreeLibrary($hModule)
        Return $bBinary
    EndFunc

    Func _GIF_MakeBitmapFromRT_BITMAP($bBinary)
       Local $tBinary = DllStructCreate("byte[" & BinaryLen($bBinary) & "]")
       DllStructSetData($tBinary, 1, $bBinary)
       Local $iHeaderSize = DllStructGetData(DllStructCreate("dword HeaderSize", DllStructGetPtr($tBinary)), "HeaderSize")
       Local $tBitmap, $iMultiplier
       Switch $iHeaderSize
          Case 40
             $tBitmap = DllStructCreate("dword HeaderSize;" & _
                   "dword Width;" & _
                   "dword Height;" & _
                   "word Planes;" & _
                   "word BitPerPixel;" & _
                   "dword CompressionMethod;" & _
                   "dword Size;" & _
                   "dword Hresolution;" & _
                   "dword Vresolution;" & _
                   "dword Colors;" & _
                   "dword ImportantColors", _
                   DllStructGetPtr($tBinary))
             $iMultiplier = 4
          Case 12
             $tBitmap = DllStructCreate("dword HeaderSize;" & _
                   "word Width;" & _
                   "word Height;" & _
                   "word Planes;" & _
                   "word BitPerPixel", _
                   DllStructGetPtr($tBinary))
             $iMultiplier = 3
          Case Else
             Return SetError(1, 0, 0)
       EndSwitch
       Local $iExponent = DllStructGetData($tBitmap, "BitPerPixel")
       Local $tDIB = DllStructCreate("align 2;char Identifier[2];" & _
             "dword BitmapSize;" & _
             "short;" & _
             "short;" & _
             "dword BitmapOffset;" & _
             "byte Body[" & BinaryLen($bBinary) & "]")
       DllStructSetData($tDIB, "Identifier", "BM")
       DllStructSetData($tDIB, "BitmapSize", BinaryLen($bBinary) + 14)
       Local $iRawBitmapSize = DllStructGetData($tBitmap, "Size")
       If $iRawBitmapSize Then
          DllStructSetData($tDIB, "BitmapOffset", BinaryLen($bBinary) - $iRawBitmapSize + 14)
       Else
          If $iExponent = 24 Then
             DllStructSetData($tDIB, "BitmapOffset", $iHeaderSize + 14)
          Else
             Local $iWidth = DllStructGetData($tBitmap, "Width")
             Local $iHeight = DllStructGetData($tBitmap, "Height")
             $iRawBitmapSize = 4 * Floor(($iWidth * $iExponent + 31) / 32) * $iHeight
             Local $iOffset1 = BinaryLen($bBinary) - $iRawBitmapSize + 14
             Local $iOffset2 = 2 ^ $iExponent * $iMultiplier + $iHeaderSize + 14
             If $iOffset2 < $iOffset1 Then
                DllStructSetData($tDIB, "BitmapOffset", $iOffset2)
             Else
                DllStructSetData($tDIB, "BitmapOffset", $iOffset1 - 2)
             EndIf
          EndIf
       EndIf
       DllStructSetData($tDIB, "Body", $bBinary)
       Return DllStructGetData(DllStructCreate("byte[" & DllStructGetSize($tDIB) & "]", DllStructGetPtr($tDIB)), 1)
    EndFunc

    Func _GIF_SwapEndian($iValue, $iSize = 0)
       If $iSize Then
          Local $sPadd = "00000000"
          Return Hex(BinaryMid($iValue, 1, $iSize)) & StringLeft($sPadd, 2 * ($iSize - BinaryLen($iValue)))
       EndIf
       Return Hex(Binary($iValue))
    EndFunc

    Func _GIF_GetGIFAssoc($iGIFId)
       Local $aArray = StringRegExp($sGIF__ASSOCSTRING_INTERNAL, "(?i);" & $iGIFId & "\|(.*?);", 3)
       If @error Then Return 0
       Return Ptr($aArray[0])
    EndFunc

    aut
    aut
    PSsix Powerful Scripting Class
    PSsix Powerful Scripting Class


    PSsix Game Coder
    จำนวนข้อความ : 472
    ความนิยม : 126
    เข้าร่วมเมื่อ : 24/07/2010

    วิธีสร้าง Animation GIF ใน AutoIt Empty Re: วิธีสร้าง Animation GIF ใน AutoIt

    ตั้งหัวข้อ by aut 03/05/11, 10:27 am

    quote เด๋วมานเปี่ยนหนีอีกรอการยำรอบใหม่นะนาย เหอๆ กลับมามัวกว่าคราวก่อนอีก เฮ้อ....สงสานคนอ่านจังนะป้อนยาพิดให้คนไปเรือย เด๋วคนตายหมดบอดเลยทำงัย เก่งก้อไม่ได้เก่งอารายอวยตัวเองนี่ไม่อายหรา แม่งไม่รู้จิงสักย่าง นายนะศึกษาเขียนโปรแกรมมานไม่ใช่หมอดูนะ ไม่รู้ไม่แน่จัยอารายแล้วคิดว่ามานจะเป็นอย่างั้นอย่างงี้เอามาสอนคนอื่นมัว มันจะกลายเป็นความรู้หรา บ้าเป่าวะ แย้วเที่ยวไปตอบกะทู้มัวไปเรือยไม่ตงคำถามอีกเต็มบอด เฮ้อ......จะแกล้งคนในบอดอะเป่า



    sak20102005 พิมพ์ว่า:ทีแรกจะลง source code ให้ไปศึกษากันเอง แต่มาคิดอีกที คงจะไม่ได้สาระความรู้ซักเท่าไหร่ ถ้าไม่มีการอธิบายโค๊ด
    คนที่เก่งก็หวงวิชา หรือรู้วิธีแต่ไม่สามารถบรรยายออกมาเป็นบทความได้ หรือว่าขี้เกียจเขียนบทความ ก็สุดจะเดา
    คนที่เขียนโค๊ด AutoIt เก่งๆ ..การสร้างภาพเอนิเมชั่นด้วยการเขียนคำสั่ง Autoit ไม่ใช่เรื่องยาก เพราะเขารู้ว่าจะเขียนยังไง
    ในขั้นตอนเดียวแล้วสามารถแสดงผลภาพเมนิชั่นออกมาได้ แต่สำหรับเราๆท่านๆคงต้องพึ่งสคริ๊ป includ กันไปก่อน
    เพราะจะทำให้ไม่ต้องเขียนคำสั่งทั้งหมดแบบยาวๆ ลงสคริ๊ป includ ไว้ให้ก่อน
    คราวหน้าเรามาลองศึกษาการเขียนคำสั่ง Autoit เพื่อสร้างภาพเอนิเมชั่นกัน

    includ script: GIFAnimation.au3
    Code:

    #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
    #include-once

    Global Const $hGIFDLL__KERNEL32 = DllOpen("kernel32.dll")
    Global Const $hGIFDLL__USER32 = DllOpen("user32.dll")
    Global Const $hGIFDLL__GDI32 = DllOpen("gdi32.dll")
    Global Const $hGIFDLL__COMCTL32 = DllOpen("comctl32.dll")
    Global Const $hGIFDLL__OLE32 = DllOpen("ole32.dll")
    Global Const $hGIFDLL__GDIPLUS = DllOpen("gdiplus.dll")
    Global $sGIF__ASSOCSTRING_INTERNAL = ";"

    Func _GIF_DeleteGIF($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)
       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;", _
             $pGIF)
       Local $hGIFThread = DllStructGetData($tGIF, "GIFThread")
       If $hGIFThread Then
           _GIF_ResumeThread($hGIFThread)
          DllStructSetData($tGIF, "ExitFlag", 1)
          _GIF_WaitForSingleObject($hGIFThread)
          _GIF_CloseHandle($hGIFThread)
       EndIf
        Local $pCodeBuffer = DllStructGetData($tGIF, "CodeBuffer")
       If $pCodeBuffer Then _GIF_MemGlobalFree($pCodeBuffer)
       Local $hImageList = DllStructGetData($tGIF, "ImageList")
       If $hImageList Then _GIF_ImageList_Destroy($hImageList)
       _GIF_MemGlobalFree($pGIF)
        Local $hGIFControl = _GIF_GetDlgCtrlID(DllStructGetData($tGIF, "ControlHandle"))
       _GIF_DeleteObject(GUICtrlSendMsg($hGIFControl, 370, 0, 0))
       GUICtrlDelete($hGIFControl)
       $sGIF__ASSOCSTRING_INTERNAL = StringReplace($sGIF__ASSOCSTRING_INTERNAL, $hGIFControl & "|" & $pGIF & ";", "")
       Return 1
    EndFunc

    Func _GIF_ExitAnimation($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)
       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;" & _
             "bool Transparent;" & _
             "dword CurrentFrame;", _
             $pGIF)
       Local $hGIFThread = DllStructGetData($tGIF, "GIFThread")
       If $hGIFThread Then
          _GIF_ResumeThread($hGIFThread)
           DllStructSetData($tGIF, "ExitFlag", 1)
          _GIF_WaitForSingleObject($hGIFThread)
          _GIF_CloseHandle($hGIFThread)
          DllStructSetData($tGIF, "GIFThread", 0)
       EndIf
       Local $pCodeBuffer = DllStructGetData($tGIF, "CodeBuffer")
       If $pCodeBuffer Then _GIF_MemGlobalFree($pCodeBuffer)
       DllStructSetData($tGIF, "CodeBuffer", 0)
       Local $hImageList = DllStructGetData($tGIF, "ImageList")
       If $hImageList Then _GIF_ImageList_Destroy($hImageList)
       DllStructSetData($tGIF, "ImageList", 0)
       DllStructSetData($tGIF, "CurrentFrame", 0)
       Local $hGIFControl = _GIF_GetDlgCtrlID(DllStructGetData($tGIF, "ControlHandle"))
       GUICtrlSetState($hGIFControl, GUICtrlGetState($hGIFControl))
       Return 1
    EndFunc

    Func _GIF_GetCurrentFrame($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)
       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;" & _
             "bool Transparent;" & _
             "dword CurrentFrame;", _
             $pGIF)
       Return DllStructGetData($tGIF, "CurrentFrame")
    EndFunc

    Func _GIF_GetDimension($vGIF, $vAdditionalData = "")
       Local $aOut[2] = [0, 0]
       Local $vData
       If IsBinary($vGIF) Then
          $vData = $vGIF
       Else
          If $vAdditionalData Then
             Local $aData = StringSplit($vAdditionalData, ";", 2)
             If UBound($aData) < 3 Then ReDim $aData[3]
             $vData = _GIF_ResourceGetAsRaw($vGIF, $aData[0], $aData[1], $aData[2])
             If @error Then
                $vData = $vGIF
             Else
                If $aData[0] = 2 Then $vData = _GIF_MakeBitmapFromRT_BITMAP($vData)
             EndIf
          Else
             $vData = $vGIF
          EndIf
       EndIf
       Local $hGDIP
       Local $hMemGlobal
       Local $pBitmap, $iWidth, $iHeight
       If IsString($vData) Then
          $pBitmap = _GIF_CreateBitmapFromFile($hGDIP, $vData, $iWidth, $iHeight)
          If @error Then $pBitmap = _GIF_CreateBitmapFromBinaryImage($hGDIP, $hMemGlobal, Binary($vData), $iWidth, $iHeight)
          If @error Then
             Local $hGIFFile = FileOpen($vData)
             $vData = FileRead($hGIFFile)
             FileClose($hGIFFile)
             $pBitmap = _GIF_CreateBitmapFromBinaryImage($hGDIP, $hMemGlobal, $vData, $iWidth, $iHeight)
          EndIf
       Else
          $pBitmap = _GIF_CreateBitmapFromBinaryImage($hGDIP, $hMemGlobal, $vData, $iWidth, $iHeight)
       EndIf
       If @error Then Return SetError(1, 0, $aOut)
       _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
       $aOut[0] = $iWidth
       $aOut[1] = $iHeight
       Return $aOut
    EndFunc

    Func _GIF_GetSize($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)
       Local $aOut[2] = [0, 0]
       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;", _
             $pGIF)
       Local $hImageList = DllStructGetData($tGIF, "ImageList")
       If $hImageList Then Return _GIF_ImageList_GetIconSize($hImageList)
       Local $hControl = DllStructGetData($tGIF, "ControlHandle")
       If Not $hControl Then Return SetError(1, 0, $aOut)
       Local $aArray = WinGetPos($hControl)
       If @error Then Return SetError(1, 0, $aOut)
       $aOut[0] = $aArray[2]
       $aOut[1] = $aArray[3]
       Return $aOut
    EndFunc

    Func _GIF_PauseAnimation($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)
       Local $tGIF = DllStructCreate("handle GIFThread;", $pGIF)
       Local $hGIFThread = DllStructGetData($tGIF, "GIFThread")
       If Not $hGIFThread Then Return SetExtended(1, 1)
       If _GIF_SuspendThread($hGIFThread) Then _GIF_ResumeThread($hGIFThread)
       Return 1
    EndFunc

    Func _GIF_RefreshGIF($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)

       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;" & _
             "bool Transparent;" & _
             "dword CurrentFrame;", _
             $pGIF)
       If @error Then Return SetError(1, 0, 0)
       If Not DllStructGetData($tGIF, "ImageList") Then Return 1
       Local $hDC = _GIF_GetDC(DllStructGetData($tGIF, "ControlHandle"))
       If @error Then Return SetError(2, 0, 0)
       Local $iColorRef = -1
       If DllStructGetData($tGIF, "Transparent") Then $iColorRef = _GIF_GetUnderlyingColor(DllStructGetData($tGIF, "ControlHandle"))
       _GIF_ImageList_DrawEx(DllStructGetData($tGIF, "ImageList"), DllStructGetData($tGIF, "CurrentFrame"), $hDC, 0, 0, 0, 0, $iColorRef, -1, 0)
       _GIF_ReleaseDC(0, $hDC)
       Return 1
    EndFunc

    Func _GIF_ResumeAnimation($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)
       Local $tGIF = DllStructCreate("handle GIFThread;", $pGIF)
        Local $hGIFThread = DllStructGetData($tGIF, "GIFThread")
       If Not $hGIFThread Then Return SetExtended(1, 1)
       If _GIF_ResumeThread($hGIFThread) = 2 Then _GIF_SuspendThread($hGIFThread)
       Return 1
    EndFunc

    Func _GIF_ValidateGIF($iGIFId)
       Local $pGIF = _GIF_GetGIFAssoc($iGIFId)
       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;" & _
             "bool Transparent;" & _
             "dword CurrentFrame;" & _
             "dword NumberOfFrames;", _
             $pGIF)
       If @error Then Return SetError(1, 0, 0)
       If DllStructGetData($tGIF, "NumberOfFrames") < 2 Then Return 1
       If Not DllStructGetData($tGIF, "GIFThread") Then Return 1
       _GIF_RedrawWindow(DllStructGetData($tGIF, "ControlHandle"), 0, 0, 1280)
       _GIF_RefreshGIF($pGIF)
       Return 1
    EndFunc

    Func _GUICtrlCreateGIF($vGIF, $vAdditionalData, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iRenderingStyle = Default, $iForcedARGB = Default)
       If $iWidth = -1 Then $iWidth = Default
       If $iHeight = -1 Then $iHeight = Default
       Local $vData
       If IsBinary($vGIF) Then
          $vData = $vGIF
       Else
          If $vAdditionalData Then
             Local $aData = StringSplit($vAdditionalData, ";", 2)
             If UBound($aData) < 3 Then ReDim $aData[3]
             $vData = _GIF_ResourceGetAsRaw($vGIF, $aData[0], $aData[1], $aData[2])
             If @error Then
                $vData = $vGIF
             Else
                If $aData[0] = 2 Then $vData = _GIF_MakeBitmapFromRT_BITMAP($vData)
             EndIf
          Else
             $vData = $vGIF
          EndIf
       EndIf
       Local $hGIFControl, $iWidthDef, $iHeightDef
       If Not IsKeyword($iWidthDef) Then $iWidthDef = $iWidth
       If Not IsKeyword($iHeightDef) Then $iHeightDef = $iHeight
       Local $pGIF = _GIF_Create_pGIF($vData, $iWidthDef, $iHeightDef, $hGIFControl, $iLeft, $iTop, $iForcedARGB)
       If @error Then
          Local $hGIFFile = FileOpen($vData)
          $vData = FileRead($hGIFFile)
          FileClose($hGIFFile)
          $pGIF = _GIF_Create_pGIF($vData, $iWidthDef, $iHeightDef, $hGIFControl, $iLeft, $iTop, $iForcedARGB)
          If @error Then
             $pGIF = _GIF_Create_pGIF(Binary($vGIF), $iWidthDef, $iHeightDef, $hGIFControl, $iLeft, $iTop, $iForcedARGB)
             If @error Then Return SetError(1, @extended = True, 0)
          EndIf
       EndIf
       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;" & _
             "bool Transparent;" & _
             "dword CurrentFrame;" & _
             "dword NumberOfFrames;", _
             $pGIF)
       Local $iFrameCount = DllStructGetData($tGIF, "NumberOfFrames")
       $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;" & _
             "bool Transparent;" & _
             "dword CurrentFrame;" & _
             "dword NumberOfFrames;" & _
             "dword FrameDelay[" & $iFrameCount & "];", _
             $pGIF)
       GUICtrlSetResizing($hGIFControl, 802)
       DllStructSetData($tGIF, "ControlHandle", GUICtrlGetHandle($hGIFControl))
       If $iFrameCount = 1 Then
          $sGIF__ASSOCSTRING_INTERNAL &= $hGIFControl & "|" & $pGIF & ";"
          Return SetExtended(1, $hGIFControl)
       EndIf
       Local $iSizeCodeBuffer = 181
       If @AutoItX64 Then $iSizeCodeBuffer = 274
       Local $pCodeBuffer = _GIF_MemGlobalAlloc($iSizeCodeBuffer, 64)
       If @error Then Return SetError(2, 0, $hGIFControl)
       DllStructSetData($tGIF, "CodeBuffer", $pCodeBuffer)
       _GIF_VirtualProtect($pCodeBuffer, $iSizeCodeBuffer, 64)
       If @error Then Return SetError(3, 0, $hGIFControl)
       Local $tCodeBuffer = DllStructCreate("byte[" & $iSizeCodeBuffer & "]", $pCodeBuffer)
       Local $pImageList_DrawEx = _GIF_GetAddress(_GIF_GetModuleHandle("comctl32.dll"), "ImageList_DrawEx")
       If @error Then Return SetError(4, 1, $hGIFControl)
       Local $pSleep = _GIF_GetAddress(_GIF_GetModuleHandle("kernel32.dll"), "Sleep")
       If @error Then Return SetError(4, 2, $hGIFControl)
       Local $pGetPixel = _GIF_GetAddress(_GIF_GetModuleHandle("gdi32.dll"), "GetPixel")
       If @error Then Return SetError(4, 3, $hGIFControl)
       Local $hUser32 = _GIF_GetModuleHandle("user32.dll")
       Local $pGetDC = _GIF_GetAddress($hUser32, "GetDC")
       If @error Then Return SetError(4, 4, $hGIFControl)
       Local $pReleaseDC = _GIF_GetAddress($hUser32, "ReleaseDC")
       If @error Then Return SetError(4, 5, $hGIFControl)
       Local $pGetParent = _GIF_GetAddress($hUser32, "GetParent")
       If @error Then Return SetError(4, 6, $hGIFControl)
        Local $hImageList = DllStructGetData($tGIF, "ImageList")
       Local $hControl = DllStructGetData($tGIF, "ControlHandle")
       Local $iStyle
       If $iRenderingStyle = Default Then
          $iStyle = 1
          If DllStructGetData($tGIF, "Transparent") Then $iStyle = 0
       Else
          $iStyle = $iRenderingStyle
       EndIf
       If @AutoItX64 Then
          DllStructSetData($tCodeBuffer, 1, _
                "0x" & _
                "4883EC" & _GIF_SwapEndian(88, 1) & _
                "" & _
                "4831F6" & _
                "" & _
                "" & _
                "8BC6" & _
                "A3" & _GIF_SwapEndian(DllStructGetPtr($tGIF, "CurrentFrame"), 8) & _
                "" & _
                "48B9" & _GIF_SwapEndian($hControl, 8) & _
                "48B8" & _GIF_SwapEndian($pGetParent, 8) & _
                "FFD0" & _
                "" & _
                "4889C1" & _
                "48B8" & _GIF_SwapEndian($pGetDC, 8) & _
                "FFD0" & _
                "" & _
                "4889C3" & _
                "" & _
                "49C7C0" & _GIF_SwapEndian($iTop, 4) & _
                "BA" & _GIF_SwapEndian($iLeft, 4) & _
                "4889C1" & _
                "48B8" & _GIF_SwapEndian($pGetPixel, 8) & _
                "FFD0" & _
                "89442438" & _
                "" & _
                "4889DA" & _
                "48B9" & _GIF_SwapEndian(0, 8) & _
                "48B8" & _GIF_SwapEndian($pReleaseDC, 8) & _
                "FFD0" & _
                "89442448" & _
                "" & _
                "48B9" & _GIF_SwapEndian($hControl, 8) & _
                "48B8" & _GIF_SwapEndian($pGetDC, 8) & _
                "FFD0" & _
                "" & _
                "4889C3" & _
                "4989C0" & _
                "49C7C1" & _GIF_SwapEndian(0, 4) & _
                "89F2" & _
                "48B9" & _GIF_SwapEndian($hImageList, 8) & _
                "" & _
                "48B8" & _GIF_SwapEndian($pImageList_DrawEx, 8) & _
                "FFD0" & _
                "" & _
                "4889DA" & _
                "48B9" & _GIF_SwapEndian(0, 8) & _
                "48B8" & _GIF_SwapEndian($pReleaseDC, 8) & _
                "FFD0" & _
                "" & _
                "A1" & _GIF_SwapEndian(DllStructGetPtr($tGIF, "ExitFlag"), 8) & _
                "85C0" & _
                "75" & _GIF_SwapEndian(46, 1) & _
                "" & _
                "48BB" & _GIF_SwapEndian(DllStructGetPtr($tGIF, "FrameDelay"), 8) & _
                "488B0CB3" & _
                "48B8" & _GIF_SwapEndian($pSleep, 8) & _
                "FFD0" & _
                "" & _
                "FFC6" & _
                "" & _
                "81FE" & _GIF_SwapEndian($iFrameCount, 4) & _
                "" & _
                "74" & _GIF_SwapEndian(5, 1) & _
                "E9" & _GIF_SwapEndian(-254, 4) & _
                "E9" & _GIF_SwapEndian(-262, 4) & _
                "" & _
                "4831C0" & _
                "4883C4" & _GIF_SwapEndian(88, 1) & _
                "C3" _
                )
       Else
          DllStructSetData($tCodeBuffer, 1, _
                "0x" & _
                "" & _
                "33F6" & _
                "" & _
                "" & _
                "8BC6" & _
                "A3" & _GIF_SwapEndian(DllStructGetPtr($tGIF, "CurrentFrame"), 4) & _
                "68" & _GIF_SwapEndian($iStyle, 4) & _
                "68" & _GIF_SwapEndian(-1, 4) & _
                "" & _
                "68" & _GIF_SwapEndian($hControl, 4) & _
                "B8" & _GIF_SwapEndian($pGetParent, 4) & _
                "FFD0" & _
                "" & _
                "50" & _
                "B8" & _GIF_SwapEndian($pGetDC, 4) & _
                "FFD0" & _
                "" & _
                "8BD8" & _
                "68" & _GIF_SwapEndian($iTop, 4) & _
                "68" & _GIF_SwapEndian($iLeft, 4) & _
                "" & _
                "53" & _
                "B8" & _GIF_SwapEndian($pGetPixel, 4) & _
                "FFD0" & _
                "50" & _
                "" & _
                "53" & _
                "68" & _GIF_SwapEndian(0, 4) & _
                "B8" & _GIF_SwapEndian($pReleaseDC, 4) & _
                "FFD0" & _
                "68" & _GIF_SwapEndian(0, 4) & _
                "68" & _GIF_SwapEndian(0, 4) & _
                "68" & _GIF_SwapEndian(0, 4) & _
                "68" & _GIF_SwapEndian(0, 4) & _
                "" & _
                "68" & _GIF_SwapEndian($hControl, 4) & _
                "B8" & _GIF_SwapEndian($pGetDC, 4) & _
                "FFD0" & _
                "" & _
                "8BD8" & _
                "50" & _
                "56" & _
                "68" & _GIF_SwapEndian($hImageList, 4) & _
                "" & _
                "B8" & _GIF_SwapEndian($pImageList_DrawEx, 4) & _
                "FFD0" & _
                "" & _
                "53" & _
                "68" & _GIF_SwapEndian(0, 4) & _
                "B8" & _GIF_SwapEndian($pReleaseDC, 4) & _
                "FFD0" & _
                "" & _
                "A1" & _GIF_SwapEndian(DllStructGetPtr($tGIF, "ExitFlag"), 4) & _
                "85C0" & _
                "75" & _GIF_SwapEndian(35, 1) & _
                "" & _
                "BB" & _GIF_SwapEndian(DllStructGetPtr($tGIF, "FrameDelay"), 4) & _
                "8B0CB3" & _
                "51" & _
                "B8" & _GIF_SwapEndian($pSleep, 4) & _
                "FFD0" & _
                "" & _
                "46" & _
                "" & _
                "81FE" & _GIF_SwapEndian($iFrameCount, 4) & _
                "" & _
                "74" & _GIF_SwapEndian(5, 1) & _
                "E9" & _GIF_SwapEndian(-171, 4) & _
                "E9" & _GIF_SwapEndian(-178, 4) & _
                "" & _
                "33C0" & _
                "C3" _
                )
       EndIf
       Local $hThread = _GIF_CreateThread($pCodeBuffer)
       If @error Then Return SetError(5, 0, $hGIFControl)
       DllStructSetData($tGIF, "GIFThread", $hThread)
       _GIF_InvalidateRect(_GIF_GetParent($hControl))
       $sGIF__ASSOCSTRING_INTERNAL &= $hGIFControl & "|" & $pGIF & ";"
       Return $hGIFControl
    EndFunc

    Func _GIF_CloseHandle($hHandle)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "bool", "CloseHandle", "handle", $hHandle)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_WaitForSingleObject($hHandle, $iMiliSec = -1)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "dword", "WaitForSingleObject", "handle", $hHandle, "dword", $iMiliSec)
       If @error Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_CreateThread($pAddress)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "handle", "CreateThread", _
             "ptr", 0, _
             "dword_ptr", 0, _
             "ptr", $pAddress, _
             "ptr", 0, _
             "dword", 0, _
             "dword*", 0)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_SuspendThread($hTread)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "dword", "SuspendThread", "handle", $hTread)
       If @error Or $aCall[0] = -1 Then Return SetError(1, 0, -1)
       Return $aCall[0]
    EndFunc

    Func _GIF_ResumeThread($hTread)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "dword", "ResumeThread", "handle", $hTread)
       If @error Or $aCall[0] = -1 Then Return SetError(1, 0, -1)
       Return $aCall[0]
    EndFunc

    Func _GIF_VirtualProtect($pAddress, $iSize, $iProtection)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "bool", "VirtualProtect", "ptr", $pAddress, "dword_ptr", $iSize, "dword", $iProtection, "dword*", 0)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GetAddress($hModule, $vFuncName)
       Local $sType = "str"
       If IsNumber($vFuncName) Then $sType = "int"
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "ptr", "GetProcAddress", "handle", $hModule, $sType, $vFuncName)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_GetModuleHandle($vModule = 0)
       Local $sType = "wstr"
       If Not $vModule Then $sType = "ptr"
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "ptr", "GetModuleHandleW", $sType, $vModule)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_GetBkColor($hWnd)
       Local $hDC = _GIF_GetDC($hWnd)
       If @error Then Return SetError(1, 0, -1)
       Local $aCall = DllCall($hGIFDLL__GDI32, "dword", "GetBkColor", "handle", $hDC)
       If @error Or $aCall[0] = -1 Then
          _GIF_ReleaseDC($hWnd, $hDC)
          Return SetError(2, 0, -1)
       EndIf
       _GIF_ReleaseDC($hWnd, $hDC)
       Return $aCall[0]
    EndFunc

    Func _GIF_GetDC($hWnd)
       Local $aCall = DllCall($hGIFDLL__USER32, "handle", "GetDC", "hwnd", $hWnd)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_ReleaseDC($hWnd, $hDC)
       Local $aCall = DllCall($hGIFDLL__USER32, "int", "ReleaseDC", "hwnd", $hWnd, "handle", $hDC)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GetDlgCtrlID($hWnd)
       Local $aCall = DllCall($hGIFDLL__USER32, "int", "GetDlgCtrlID", "hwnd", $hWnd)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_InvalidateRect($hWnd, $pRect = 0, $fErase = True)
       Local $aCall = DllCall($hGIFDLL__USER32, "bool", "InvalidateRect", _
             "hwnd", $hWnd, _
             "ptr", $pRect, _
             "bool", $fErase)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_ValidateRect($hWnd, $pRect = 0)
       Local $aCall = DllCall($hGIFDLL__USER32, "bool", "ValidateRect", "hwnd", $hWnd, "ptr", $pRect)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_RedrawWindow($hWnd, $pRect, $hRegion, $iFlags)
       Local $aCall = DllCall($hGIFDLL__USER32, "bool", "RedrawWindow", "hwnd", $hWnd, "ptr", $pRect, "handle", $hRegion, "dword", $iFlags)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_GetUnderlyingColor($hWnd)
       Local $hParent = _GIF_GetParent($hWnd)
       If @error Then Return SetError(1, 0, -1)
       Local $iColor = _GIF_GetBkColor($hParent)
       Return SetError(@error, 0, $iColor)
    EndFunc

    Func _GIF_GetParent($hWnd)
       Local $aCall = DllCall($hGIFDLL__USER32, "hwnd", "GetParent", "hwnd", $hWnd)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_Create_pGIF($bBinary, ByRef $iWidth, ByRef $iHeight, ByRef $hGIFControl, $iLeft = 0, $iTop = 0, $iARGB = 0xFF000000)
       If $iARGB = Default Then $iARGB = 0xFF000000
       Local $hGDIP
       Local $hMemGlobal
       Local $pBitmap, $iWidthReal, $iHeightReal
       If IsBinary($bBinary) Then
          $pBitmap = _GIF_CreateBitmapFromBinaryImage($hGDIP, $hMemGlobal, $bBinary, $iWidthReal, $iHeightReal)
       Else
          $pBitmap = _GIF_CreateBitmapFromFile($hGDIP, $bBinary, $iWidthReal, $iHeightReal)
       EndIf
       If @error Then
          Local $iErr = @error
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
          Return SetError(1, $iErr, 0)
       EndIf
       Local $fDoResize
       If $iWidth = Default Then
          $iWidth = $iWidthReal
       Else
          $fDoResize = True
       EndIf
       If $iHeight = Default Then
          $iHeight = $iHeightReal
       Else
          $fDoResize = True
       EndIf
       Local $iFrameDimensionsCount = _GIF_GdipImageGetFrameDimensionsCount($pBitmap)
       If @error Then
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
          Return SetError(2, 0, 0)
       EndIf
       Local $tGUID = DllStructCreate("dword;word;word;byte[8]")
       Local $pGUID = DllStructGetPtr($tGUID)
       _GIF_GdipImageGetFrameDimensionsList($pBitmap, $pGUID, $iFrameDimensionsCount)
       If @error Then
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
          Return SetError(3, 0, 0)
       EndIf
       Local $iFrameCount = _GIF_GdipImageGetFrameCount($pBitmap, $pGUID)
       If @error Then
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
          Return SetError(4, 0, 0)
       EndIf
       Local $pGIF = _GIF_MemGlobalAlloc(4 * (8 + 4 * @AutoItX64 + $iFrameCount), 64)
       If @error Then
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
          Return SetError(3, 0, 0)
       EndIf
       Local $tGIF = DllStructCreate("handle GIFThread;" & _
             "ptr CodeBuffer;" & _
             "hwnd ControlHandle;" & _
             "handle ImageList;" & _
             "bool ExitFlag;" & _
             "bool Transparent;" & _
             "dword CurrentFrame;" & _
             "dword NumberOfFrames;" & _
             "dword FrameDelay[" & $iFrameCount & "];", _
             $pGIF)
       DllStructSetData($tGIF, "GIFThread", 0)
       DllStructSetData($tGIF, "ControlHandle", 0)
       DllStructSetData($tGIF, "ExitFlag", 0)
       DllStructSetData($tGIF, "CurrentFrame", 0)
       DllStructSetData($tGIF, "NumberOfFrames", $iFrameCount)
        $hGIFControl = GUICtrlCreatePic("", $iLeft, $iTop, $iWidth, $iHeight)
       If $iFrameCount = 1 Then
          Local $hGIFBitmap = _GIF_GdipCreateHBITMAPFromBitmap($pBitmap, $iARGB)
          If $fDoResize Then _GIF_ResizeBitmap($hGIFBitmap, $iWidth, $iHeight)
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
          _GIF_DeleteObject(GUICtrlSendMsg($hGIFControl, 370, 0, $hGIFBitmap))
          _GIF_DeleteObject($hGIFBitmap)
          Return $pGIF
       EndIf
        Local $hImageList = _GIF_ImageList_Create($iWidth, $iHeight, 32, $iFrameCount)
       If @error Then
          GUICtrlDelete($hGIFControl)
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal, $pGIF)
          Return SetError(4, 0, 0)
       EndIf
       DllStructSetData($tGIF, "ImageList", $hImageList)
       Local $hBitmap
       For $j = 0 To $iFrameCount - 1
          _GIF_GdipImageSelectActiveFrame($pBitmap, $pGUID, $j)
          If @error Then ContinueLoop
          $hBitmap = _GIF_GdipCreateHBITMAPFromBitmap($pBitmap, $iARGB)
          If $fDoResize Then _GIF_ResizeBitmap($hBitmap, $iWidth, $iHeight)
               _GIF_ImageList_Add($hImageList, $hBitmap)
          If $j = 0 Then
             _GIF_DeleteObject(GUICtrlSendMsg($hGIFControl, 370, 0, $hBitmap))
             _GIF_DeleteObject($hBitmap)
          EndIf
          _GIF_DeleteObject($hBitmap)
       Next
       Local $iPropertyItemSize = _GIF_GdipGetPropertyItemSize($pBitmap, 0x5100)
       If @error Then
          GUICtrlDelete($hGIFControl)
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal, $pGIF)
          Return SetError(5, 0, 0)
       EndIf
       Local $tRawPropItem = DllStructCreate("byte[" & $iPropertyItemSize & "]")
       _GIF_GdipGetPropertyItem($pBitmap, 0x5100, $iPropertyItemSize, DllStructGetPtr($tRawPropItem))
       If @error Then
          GUICtrlDelete($hGIFControl)
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal, $pGIF)
          Return SetError(6, 0, 0)
       EndIf
       Local $tPropItem = DllStructCreate("int Id;" & _
             "dword Length;" & _
             "word Type;" & _
             "ptr Value", _
             DllStructGetPtr($tRawPropItem))
        Local $iSize = DllStructGetData($tPropItem, "Length") / 4
       Local $tPropertyData = DllStructCreate("dword[" & $iSize & "]", DllStructGetData($tPropItem, "Value"))
       Local $iDelay
       For $j = 1 To $iFrameCount
          $iDelay = DllStructGetData($tPropertyData, 1, $j) * 10
          If Not $iDelay Then $iDelay = 130
          If $iDelay < 50 Then $iDelay = 50
          DllStructSetData($tGIF, "FrameDelay", $iDelay, $j)
       Next
       Local $fTransparent = True
       Local $iPixelColor = _GIF_GdipBitmapGetPixel($pBitmap, 0, 0)
       If BitShift($iPixelColor, 24) Then $fTransparent = False
       DllStructSetData($tGIF, "Transparent", $fTransparent)
       _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
       Return $pGIF
    EndFunc

    Func _GIF_CreateStreamOnHGlobal($hGlobal, $iFlag = 1)
       Local $aCall = DllCall($hGIFDLL__OLE32, "long", "CreateStreamOnHGlobal", "handle", $hGlobal, "int", $iFlag, "ptr*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[3]
    EndFunc

    Func _GIF_GetObject($hObject, $iSize, $pObject)
       Local $aCall = DllCall($hGIFDLL__GDI32, "int", "GetObject", "handle", $hObject, "int", $iSize, "ptr", $pObject)
       If @error Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_DeleteObject($hObject)
       Local $aCall = DllCall($hGIFDLL__GDI32, "bool", "DeleteObject", "handle", $hObject)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_ImageList_GetIconSize($hImageList)
       Local $aOut[2] = [0, 0]
       Local $aCall = DllCall($hGIFDLL__COMCTL32, "bool", "ImageList_GetIconSize", "handle", $hImageList, "int*", 0, "int*", 0)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, $aOut)
       $aOut[0] = $aCall[2]
       $aOut[1] = $aCall[3]
       Return $aOut
    EndFunc

    Func _GIF_ImageList_Create($iWidth, $iHeight, $iFlag, $iInitial, $iGrow = 0)
       Local $aCall = DllCall($hGIFDLL__COMCTL32, "handle", "ImageList_Create", _
             "int", $iWidth, _
             "int", $iHeight, _
             "dword", $iFlag, _
             "int", $iInitial, _
             "int", $iGrow)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_ImageList_Add($hImageList, $hBitmap)
       Local $aCall = DllCall($hGIFDLL__COMCTL32, "int", "ImageList_Add", _
             "handle", $hImageList, _
             "handle", $hBitmap, _
             "handle", 0)
       If @error Or $aCall[0] = -1 Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_ImageList_Destroy($hImageList)
       Local $aCall = DllCall($hGIFDLL__COMCTL32, "bool", "ImageList_Destroy", "handle", $hImageList)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_ImageList_DrawEx($hImageList, $iImageIndex, $hDC, $iXPos = 0, $iYPos = 0, $iWidth = 0, $iHeight = 0, $iBkColRef = -1, $iFgColRef = -1, $iStyle = 0)
       Local $aCall = DllCall($hGIFDLL__COMCTL32, "bool", "ImageList_DrawEx", _
             "handle", $hImageList, _
             "int", $iImageIndex, _
             "handle", $hDC, _
             "int", $iXPos, _
             "int", $iYPos, _
             "int", $iWidth, _
             "int", $iHeight, _
             "dword", $iBkColRef, _
             "dword", $iFgColRef, _
             "dword", $iStyle)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_CreateBitmapFromFile(ByRef $hGDIP, $sFile, ByRef $iWidth, ByRef $iHeight)
       $hGDIP = _GIF_GdiplusStartup()
       If @error Then Return SetError(1, 0, 0)
       Local $pBitmap = _GIF_GdipLoadImageFromFile($sFile)
       If @error Then
          _GIF_GdiplusShutdown($hGDIP)
          Return SetError(2, 0, 0)
       EndIf
       _GIF_GdipGetImageDimension($pBitmap, $iWidth, $iHeight)
       If @error Then
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP)
          Return SetError(3, 0, 0)
       EndIf
       Return $pBitmap
    EndFunc

    Func _GIF_CreateBitmapFromBinaryImage(ByRef $hGDIP, ByRef $hMemGlobal, $bBinary, ByRef $iWidth, ByRef $iHeight)
       Local $iSize = BinaryLen($bBinary)
       $hMemGlobal = _GIF_MemGlobalAlloc($iSize, 2)
       If @error Then Return SetError(1, 0, 0)
       Local $pMemory = _GIF_MemGlobalLock($hMemGlobal)
       If @error Then
          _GIF_MemGlobalFree($hMemGlobal)
          Return SetError(2, 0, 0)
       EndIf
       Local $tBinary = DllStructCreate("byte[" & $iSize & "]", $pMemory)
       DllStructSetData($tBinary, 1, $bBinary)
       Local $pStream = _GIF_CreateStreamOnHGlobal($pMemory)
       If @error Then
          _GIF_MemGlobalFree($hMemGlobal)
          Return SetError(3, 0, 0)
       EndIf
       _GIF_MemGlobalUnlock($pMemory)
        $hGDIP = _GIF_GdiplusStartup()
       If @error Then
          _GIF_MemGlobalFree($hMemGlobal)
          Return SetError(4, 0, 0)
       EndIf
       Local $pBitmap = _GIF_GdipCreateBitmapFromStream($pStream)
       If @error Then
          _GIF_GdiplusShutdown($hGDIP)
          _GIF_MemGlobalFree($hMemGlobal)
          Return SetError(5, 0, 0)
       EndIf
       _GIF_GdipGetImageDimension($pBitmap, $iWidth, $iHeight)
       If @error Then
          _GIF_FreeGdipAndMem($pBitmap, $hGDIP, $hMemGlobal)
          Return SetError(6, 0, 0)
       EndIf
       Return $pBitmap
    EndFunc

    Func _GIF_ResizeBitmap(ByRef $hBitmap, $iNewWidth, $iNewHeight)
       Local $tBMP = DllStructCreate("long Type;long Width;long Height;long WidthBytes;word Planes;word BitsPixel;ptr Bits;")
       _GIF_GetObject($hBitmap, DllStructGetSize($tBMP), DllStructGetPtr($tBMP))
       Local $pBitmap = _GIF_GdipCreateBitmapFromScan0(DllStructGetData($tBMP, "Width"), DllStructGetData($tBMP, "Height"), DllStructGetData($tBMP, "WidthBytes"), 0x26200A, DllStructGetData($tBMP, "Bits"))
       _GIF_GdipImageRotateFlip($pBitmap, 6)
       Local $pNewBitmap = _GIF_GdipCreateBitmapFromScan0($iNewWidth, $iNewHeight)
       Local $hGraphics = _GIF_GdipGetImageGraphicsContext($pNewBitmap)
       _GIF_GdipDrawImageRect($hGraphics, $pBitmap, 0, 0, $iNewWidth, $iNewHeight)
       Local $hNewBitmap = _GIF_GdipCreateHBITMAPFromBitmap($pNewBitmap)
       _GIF_GdipDisposeImage($pBitmap)
       _GIF_GdipDeleteGraphics($hGraphics)
       _GIF_DeleteObject($hBitmap)
       _GIF_GdipDisposeImage($pNewBitmap)
        $hBitmap = $hNewBitmap
       Return 1
    EndFunc

    Func _GIF_GdiplusStartup()
       Local $tGdiplusStartupInput = DllStructCreate("dword GdiplusVersion;" & _
             "ptr DebugEventCallback;" & _
             "int SuppressBackgroundThread;" & _
             "int SuppressExternalCodecs")
       DllStructSetData($tGdiplusStartupInput, "GdiplusVersion", 1)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdiplusStartup", "dword_ptr*", 0, "ptr", DllStructGetPtr($tGdiplusStartupInput), "ptr", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[1]
    EndFunc

    Func _GIF_GdiplusShutdown($hGDIP)
       DllCall($hGIFDLL__GDIPLUS, "none", "GdiplusShutdown", "dword_ptr", $hGDIP)
    EndFunc

    Func _GIF_GdipDisposeImage($hImage)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipDisposeImage", "handle", $hImage)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GdipGetImageDimension($pBitmap, ByRef $iWidth, ByRef $iHeight)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipGetImageDimension", "ptr", $pBitmap, "float*", 0, "float*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       $iWidth = $aCall[2]
       $iHeight = $aCall[3]
    EndFunc

    Func _GIF_GdipImageGetFrameDimensionsCount($pBitmap)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipImageGetFrameDimensionsCount", "ptr", $pBitmap, "dword*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[2]
    EndFunc

    Func _GIF_GdipImageGetFrameDimensionsList($pBitmap, $pGUID, $iFrameDimensionsCount)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipImageGetFrameDimensionsList", _
             "ptr", $pBitmap, _
             "ptr", $pGUID, _
             "dword", $iFrameDimensionsCount)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GdipImageGetFrameCount($pBitmap, $pGUID)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipImageGetFrameCount", _
             "ptr", $pBitmap, _
             "ptr", $pGUID, _
             "dword*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[3]
    EndFunc

    Func _GIF_GdipImageSelectActiveFrame($pBitmap, $pGUID, $iFrameIndex)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipImageSelectActiveFrame", _
             "ptr", $pBitmap, _
             "ptr", $pGUID, _
             "dword", $iFrameIndex)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GdipGetPropertyItemSize($pBitmap, $iPropID)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipGetPropertyItemSize", _
             "ptr", $pBitmap, _
             "ptr", $iPropID, _
             "dword*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[3]
    EndFunc

    Func _GIF_GdipGetPropertyItem($pBitmap, $iPropID, $iSize, $pBuffer)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipGetPropertyItem", _
             "ptr", $pBitmap, _
             "dword", $iPropID, _
             "dword", $iSize, _
             "ptr", $pBuffer)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GdipBitmapGetPixel($pBitmap, $iX, $iY)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipBitmapGetPixel", _
             "ptr", $pBitmap, _
             "int", $iX, _
             "int", $iY, _
             "dword*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[4]
    EndFunc

    Func _GIF_GdipLoadImageFromFile($sFile)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipLoadImageFromFile", "wstr", $sFile, "ptr*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[2]
    EndFunc

    Func _GIF_GdipCreateBitmapFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x26200A, $pScan0 = 0)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "dword", $iPixelFormat, "ptr", $pScan0, "ptr*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[6]
    EndFunc

    Func _GIF_GdipCreateBitmapFromStream($pStream)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipCreateBitmapFromStream", "ptr", $pStream, "ptr*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[2]
    EndFunc

    Func _GIF_GdipCreateHBITMAPFromBitmap($pBitmap, $iARGB = 0xFF000000)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipCreateHBITMAPFromBitmap", "ptr", $pBitmap, "handle*", 0, "dword", $iARGB)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[2]
    EndFunc

    Func _GIF_GdipGetImageGraphicsContext($hImage)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipGetImageGraphicsContext", "ptr", $hImage, "ptr*", 0)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[2]
    EndFunc

    Func _GIF_GdipDrawImageRect($hGraphics, $hImage, $iX, $iY, $iWidth, $iHeight)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipDrawImageRectI", "ptr", $hGraphics, "ptr", $hImage, "int", $iX, "int", $iY, "int", $iWidth, "int", $iHeight)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GdipDeleteGraphics($hGraphics)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipDeleteGraphics", "handle", $hGraphics)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_GdipImageRotateFlip($hImage, $iType)
       Local $aCall = DllCall($hGIFDLL__GDIPLUS, "dword", "GdipImageRotateFlip", "handle", $hImage, "dword", $iType)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_FreeGdipAndMem($pBitmap = 0, $hGDIP = 0, $hMem = 0, $pGIF = 0)
       If $pBitmap Then _GIF_GdipDisposeImage($pBitmap)
       If $hGDIP Then _GIF_GdiplusShutdown($hGDIP)
       If $hMem Then _GIF_MemGlobalFree($hMem)
       If $pGIF Then _GIF_MemGlobalFree($pGIF)
    EndFunc

    Func _GIF_MemGlobalAlloc($iSize, $iFlag)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "handle", "GlobalAlloc", "dword", $iFlag, "dword_ptr", $iSize)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_MemGlobalFree($hMem)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "ptr", "GlobalFree", "handle", $hMem)
       If @error Or $aCall[0] Then Return SetError(1, 0, 0)
       Return 1
    EndFunc

    Func _GIF_MemGlobalLock($hMem)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "ptr", "GlobalLock", "handle", $hMem)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_MemGlobalUnlock($hMem)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "bool", "GlobalUnlock", "handle", $hMem)
       If @error Then Return SetError(1, 0, 0)
       If $aCall[0] Or _GIF_GetLastError() Then Return $aCall[0]
       Return 1
    EndFunc

    Func _GIF_GetLastError()
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "dword", "GetLastError")
       If @error Then Return SetError(1, 0, -1)
       Return $aCall[0]
    EndFunc

    Func _GIF_FindResourceEx($hModule, $vResType, $vResName, $iResLang = 0)
       Local $sTypeType = "wstr"
       If $vResType == Number($vResType) Then $sTypeType = "int"
       Local $sNameType = "wstr"
       If $vResName == Number($vResName) Then $sNameType = "int"
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "handle", "FindResourceExW", _
             "handle", $hModule, _
             $sTypeType, $vResType, _
             $sNameType, $vResName, _
             "int", $iResLang)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_SizeofResource($hModule, $hResource)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "int", "SizeofResource", "handle", $hModule, "handle", $hResource)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_LoadResource($hModule, $hResource)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "handle", "LoadResource", "handle", $hModule, "handle", $hResource)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_LockResource($hResource)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "ptr", "LockResource", "handle", $hResource)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_LoadLibraryEx($sModule, $iFlag = 0)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "handle", "LoadLibraryExW", "wstr", $sModule, "handle", 0, "dword", $iFlag)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_FreeLibrary($hModule)
       Local $aCall = DllCall($hGIFDLL__KERNEL32, "bool", "FreeLibrary", "handle", $hModule)
       If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
       Return $aCall[0]
    EndFunc

    Func _GIF_ResourceGetAsRaw($sModule, $vResType, $vResName, $iResLang = 0)
       Local $hModule = _GIF_LoadLibraryEx($sModule, 2)
       If @error Then Return SetError(1, 0, "")
       Local $hResource = _GIF_FindResourceEx($hModule, $vResType, $vResName, $iResLang)
       If @error Then
          _GIF_FreeLibrary($hModule)
          Return SetError(2, 0, "")
       EndIf
       Local $iSizeOfResource = _GIF_SizeofResource($hModule, $hResource)
       If @error Then
          _GIF_FreeLibrary($hModule)
          Return SetError(3, 0, "")
       EndIf
       $hResource = _GIF_LoadResource($hModule, $hResource)
       If @error Then
          _GIF_FreeLibrary($hModule)
          Return SetError(4, 0, "")
       EndIf
       Local $pResource = _GIF_LockResource($hResource)
       If @error Then
          _GIF_FreeLibrary($hModule)
          Return SetError(5, 0, "")
       EndIf
       Local $tBinary = DllStructCreate("byte[" & $iSizeOfResource & "]", $pResource)
       Local $bBinary = DllStructGetData($tBinary, 1)
       _GIF_FreeLibrary($hModule)
        Return $bBinary
    EndFunc

    Func _GIF_MakeBitmapFromRT_BITMAP($bBinary)
       Local $tBinary = DllStructCreate("byte[" & BinaryLen($bBinary) & "]")
       DllStructSetData($tBinary, 1, $bBinary)
       Local $iHeaderSize = DllStructGetData(DllStructCreate("dword HeaderSize", DllStructGetPtr($tBinary)), "HeaderSize")
       Local $tBitmap, $iMultiplier
       Switch $iHeaderSize
          Case 40
             $tBitmap = DllStructCreate("dword HeaderSize;" & _
                   "dword Width;" & _
                   "dword Height;" & _
                   "word Planes;" & _
                   "word BitPerPixel;" & _
                   "dword CompressionMethod;" & _
                   "dword Size;" & _
                   "dword Hresolution;" & _
                   "dword Vresolution;" & _
                   "dword Colors;" & _
                   "dword ImportantColors", _
                   DllStructGetPtr($tBinary))
             $iMultiplier = 4
          Case 12
             $tBitmap = DllStructCreate("dword HeaderSize;" & _
                   "word Width;" & _
                   "word Height;" & _
                   "word Planes;" & _
                   "word BitPerPixel", _
                   DllStructGetPtr($tBinary))
             $iMultiplier = 3
          Case Else
             Return SetError(1, 0, 0)
       EndSwitch
       Local $iExponent = DllStructGetData($tBitmap, "BitPerPixel")
       Local $tDIB = DllStructCreate("align 2;char Identifier[2];" & _
             "dword BitmapSize;" & _
             "short;" & _
             "short;" & _
             "dword BitmapOffset;" & _
             "byte Body[" & BinaryLen($bBinary) & "]")
       DllStructSetData($tDIB, "Identifier", "BM")
       DllStructSetData($tDIB, "BitmapSize", BinaryLen($bBinary) + 14)
       Local $iRawBitmapSize = DllStructGetData($tBitmap, "Size")
       If $iRawBitmapSize Then
          DllStructSetData($tDIB, "BitmapOffset", BinaryLen($bBinary) - $iRawBitmapSize + 14)
       Else
          If $iExponent = 24 Then
             DllStructSetData($tDIB, "BitmapOffset", $iHeaderSize + 14)
          Else
             Local $iWidth = DllStructGetData($tBitmap, "Width")
             Local $iHeight = DllStructGetData($tBitmap, "Height")
             $iRawBitmapSize = 4 * Floor(($iWidth * $iExponent + 31) / 32) * $iHeight
             Local $iOffset1 = BinaryLen($bBinary) - $iRawBitmapSize + 14
             Local $iOffset2 = 2 ^ $iExponent * $iMultiplier + $iHeaderSize + 14
             If $iOffset2 < $iOffset1 Then
                DllStructSetData($tDIB, "BitmapOffset", $iOffset2)
             Else
                DllStructSetData($tDIB, "BitmapOffset", $iOffset1 - 2)
             EndIf
          EndIf
       EndIf
       DllStructSetData($tDIB, "Body", $bBinary)
       Return DllStructGetData(DllStructCreate("byte[" & DllStructGetSize($tDIB) & "]", DllStructGetPtr($tDIB)), 1)
    EndFunc

    Func _GIF_SwapEndian($iValue, $iSize = 0)
       If $iSize Then
          Local $sPadd = "00000000"
          Return Hex(BinaryMid($iValue, 1, $iSize)) & StringLeft($sPadd, 2 * ($iSize - BinaryLen($iValue)))
       EndIf
       Return Hex(Binary($iValue))
    EndFunc

    Func _GIF_GetGIFAssoc($iGIFId)
       Local $aArray = StringRegExp($sGIF__ASSOCSTRING_INTERNAL, "(?i);" & $iGIFId & "\|(.*?);", 3)
       If @error Then Return 0
       Return Ptr($aArray[0])
    EndFunc

    ชินจัง ชินจัง
    sak20102005
    sak20102005
    ระงับสมาชิก
    ระงับสมาชิก


    วิธีสร้าง Animation GIF ใน AutoIt Empty
    จำนวนข้อความ : 96
    ความนิยม : 4
    เข้าร่วมเมื่อ : 07/04/2011

    วิธีสร้าง Animation GIF ใน AutoIt Empty Re: วิธีสร้าง Animation GIF ใน AutoIt

    ตั้งหัวข้อ by sak20102005 03/05/11, 04:25 pm

    ท่านทั้งหลายอ่านข้อความที่เขาเขียนโต้ตอบผมไว้ ก็รู้ว่า.. ใครคือตัวป่วนบอร์ดตัวจริง ที่ต้องระวัง!

    ผมจะไม่สอนการเขียนบอทที่นำไปใช้ในทางที่ผิด หรือนำไปเอาเปรียบผู้อื่น เพราะมันไม่ใช่วิธีที่ลูกผู้ชายเขาทำกัน

    มีแต่คนโกงเท่านั้นที่นำไปใช้ สุดท้ายถ้ามีใครรู้นิสัยที่แท้จริง ก็จะไม่มีใครเขาอยากคบด้วย.
    sak20102005
    sak20102005
    ระงับสมาชิก
    ระงับสมาชิก


    วิธีสร้าง Animation GIF ใน AutoIt Empty
    จำนวนข้อความ : 96
    ความนิยม : 4
    เข้าร่วมเมื่อ : 07/04/2011

    วิธีสร้าง Animation GIF ใน AutoIt Empty Re: วิธีสร้าง Animation GIF ใน AutoIt

    ตั้งหัวข้อ by sak20102005 04/05/11, 11:29 pm

    ต่อไปเป็นการสร้างภาพเอนิเมชั่นแบบไม่มีพื้นหลัง (background Trans)
    ส่วนประกอบสำคัญของโค๊ดนี้คือ
    1. สคริ๊ป includ GIFAnimation.au3
    2. สคริ๊ป include WinAPI.au3

    ชุดคำสั่งสำคัญ
    1.InetGet("https://2img.net/h/i241.photobucket.com/albums/ff141/trancexx_bucket/Dance.gif", $sFile)
    หมายถึง คำสั่งดาวน์โหลดภาพเอนิเมชั่นจากอินเทอร์เน็ต ถ้าในเครื่องไม่มี
    ---------------------------------------------------------------------------
    2.1_WinAPI_SetLayeredWindowAttributes($hGui, 345, 255)
    2.2 $WS_EX_LAYERED
    2.3 GUISetBkColor(345)
    หมายถึง คำสั่งที่ทำให้มองไม่เห็น background หรือพื้นหลังของภาพ
    -----------------------------------------------------------------------
    สั่งปิดโปรแกรมหรือหยุดการแสดงผล ใช้คำสั่ง AutoItSetOption หรือ Opt() ด้วยการกดปุ่ม ESC

    Example_DancingOnMyScript.au3
    Code:

    #AutoIt3Wrapper_Au3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 5 -w 6
    #include <WindowsConstants.au3>
    #include <WinAPI.au3>
    #include "GIFAnimation.au3"

    Opt("GUICloseOnESC", 1)
    Opt("MustDeclareVars", 1)

    Global $sTempFolder = @TempDir & "\GIFS"
    DirCreate($sTempFolder)
    Global $sFile = $sTempFolder & "\Dance.gif"
    If Not FileExists($sFile) Then
        TrayTip("GIF Download", "Please wait...", 0)
        InetGet("http://i241.photobucket.com/albums/ff141/trancexx_bucket/Dance.gif", $sFile)
        TrayTip("", "", 0)
    EndIf
    If Not FileExists($sFile) Then
        MsgBox(262192, "Download", "Download failed!")
        Exit
    EndIf
    Global $aGIFDimension = _GIF_GetDimension($sFile)
    Global $hGui = GUICreate("GIF Animation", $aGIFDimension[0], _
    $aGIFDimension[1], -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
    Global $hGIF = _GUICtrlCreateGIF($sFile, "", 0, 0)
    GUICtrlSetTip(-1, "ESC to exit")
    GUISetBkColor(345)
    _WinAPI_SetLayeredWindowAttributes($hGui, 345, 255)
    _WinAPI_SetParent($hGui, 0)
    GUISetState()

    While 1
        If GUIGetMsg() = - 3 Then Exit
    WEnd
    -----------------------------------------------------------------------------------------------------------
    บางท่านสงสัยว่า.. เอ๊ะ! เมื่อดาวน์โหลดภาพเอนิเมชั่นมาแล้ว นำไปไว้ที่ไหน ที่เดสก์ทอปก็ไม่เห็นมี

    ด้วยคำสั่งนี้ครับ

    Global $sTempFolder = @TempDir & "\GIFS"
    DirCreate($sTempFolder)
    Global $sFile = $sTempFolder & "\Dance.gif"


    ภาพจะถูกเก็บไว้ในโฟลเดอร์ Temp ..คราวหน้าถ้ามีการรันโปรแกรมนี้ขึ้นมา จะไม่มีการดาวน์โหลดซ้ำอีก
    เพราะภาพเอนิเมชั่นที่ดาวน์โหลดไว้ยังคงอยู่ ..จะถูกระงับการดาวน์โหลด ด้วยคำสั่ง:

    If Not FileExists($sFile) Then
    ------------------------------------------------------------------------------------------------------------
    ถ้าท่านมีหัวคิด พลิกแพลง ดัดแปลงการเขียนคำสั่ง
    จะสามารถเขียนเป็นไฟล์ .ini เพื่อสั่งให้ดาวน์โหลดไฟล์แบบต่อเนื่องได้.
    ตัวอย่างเช่น. If IniRead() = ??? Then InetGet() เป็นต้น.


      เวลาขณะนี้ 02/05/24, 07:23 pm