Jump to content

Recommended Posts

I'm trying to display a GIF. However, the GUI should not be visible. Here is an attempt that doesn't work:

$sGIF = "MyGIF.gif"


#Include <IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WINAPI.au3>
#include <SendMessage.au3>

Global Const $SC_DRAGMOVE = 0xF012

HotKeySet("{ESC}", "_Exit")

$hGui = GUICreate("Test", 400, 300, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0xABCDEF)
$oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE, 10, 10, 380, 280)

_WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 250)
_IENavigate($oIE, $sGIF)
GUISetState()

While 1
    Switch GUIGetMsg()
       Case $GUI_EVENT_PRIMARYDOWN
            _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    EndSwitch
WEnd

Func _Exit()
    Exit

 

Link to post
Share on other sites

In my Resources UDF there is example for (transparent) animated GIF (Examples\resource_test_ani_gif.au3), so your GIF can be included in compiled EXE :

 

#AutoIt3Wrapper_Res_File_Add=gif-Green-UFO.gif, rt_rcdata, ANI_GIF_1

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
#include <WinAPI.au3>
#include <Timers.au3>

#include "resources.au3"

HotKeySet("{Esc}", "Quit")
HotKeySet("{Left}", "Left")
HotKeySet("{Right}", "Right")
HotKeySet("{Pause}", "Pause")

Global $GIF_TimerID, $hImage, $IMG_Ctrl, $GFC, $GFDC, $pDimensionIDs, $tDL
Global $Pause, $i = 0

$hGUI = GUICreate("GIF Animation", 300, 200)
GUICtrlCreateLabel("text behind GIF - test of transparency", 5, 15, 200, 25)
$IMG_Ctrl = GUICtrlCreateLabel("", 10, 10, 10, 10) ; For Drawing
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ; Transparency's working
GUISetState(@SW_SHOW)

GifInit()
; Start Animation: instead of using the time delays between frames given from GIF we use 100ms for simplicity
_Timer_SetTimer($hGUI, 100, "_Draw_Timer")

While 1
    If GUIGetMsg() = -3 Then Quit()
WEnd

Func _Draw_Timer($hWnd, $Msg, $iIDTimer, $dwTime)
    If Not $Pause Then
        If $i = $GFC Then $i = 0 ; If $i = the frame count then reset $i to 0
        GifDrawFrame($i)
        $i += 1
    EndIf
EndFunc

Func Quit()
    _Timer_KillAllTimers($hGUI)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()

    HotKeySet("{Esc}")
    HotKeySet("{Left}")
    HotKeySet("{Right}")
    HotKeySet("{Pause}")

    Exit
EndFunc

Func GifInit()
    _GDIPlus_Startup()
    ; Load your animated GIF (from file or from resources)
;~  $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\gif-Green-UFO.gif")
    $hImage = _ResourceGetAsImage("ANI_GIF_1")

    $tDL = DllStructCreate($tagGUID) ; Create a struct to hold the GUID.
    $pDimensionIDs = DllStructGetPtr($tDL) ; Get a pointer to the GUID struct.

    ; Get the FrameDimensionsCount of the loaded gif
    $GFDC = DllCall($ghGDIPDll, "int", "GdipImageGetFrameDimensionsCount", "ptr", $hImage, "int*", 0)

    ; Get the FrameDimensionsList , which fills the GUID struct by passing the GUID pointer and the FrameDimensionsCount.
    DllCall($ghGDIPDll, "int", "GdipImageGetFrameDimensionsList", "ptr", $hImage, "ptr", $pDimensionIDs, "int", $GFDC[2])

    ; Get the FrameCount of the loaded gif by passing the GUID pointer
    $GFC = DllCall($ghGDIPDll, "int", "GdipImageGetFrameCount", "int", $hImage, "ptr", $pDimensionIDs, "int*", 0)
    $GFC = $GFC[3]
EndFunc

Func GifDrawFrame($i)
    ; Select the ActiveFrame in the loaded GIF by telling it. The frame starts at 0 ($i)
    DllCall($ghGDIPDll, "int", "GdipImageSelectActiveFrame", "ptr", $hImage, "ptr", $pDimensionIDs, "int", $i)

    ; get current frame from GIF and draw it on the control
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    _SetBitmapToCtrl($IMG_Ctrl, $hBitmap)
    _WinAPI_DeleteObject($hBitmap)
EndFunc

Func Left()
    If WinActive($hGUI) Then
        If Not $Pause Then Return
        $i -= 1
        If $i = -1 Then $i = $GFC - 1
        GifDrawFrame($i)
    Else
        HotKeySet("{Left}")
        Send("{Left}")
        HotKeySet("{Left}", "Left")
    EndIf
EndFunc

Func Right()
    If WinActive($hGUI) Then
        If Not $Pause Then Return
        $i += 1
        If $i = $GFC Then $i = 0
        GifDrawFrame($i)
    Else
        HotKeySet("{Right}")
        Send("{Right}")
        HotKeySet("{Right}", "Right")
    EndIf
EndFunc

Func Pause()
    If WinActive($hGUI) Then
        $Pause = Not $Pause
        If $Pause Then
            WinSetTitle($hGUI, '', 'GIF Animation - PAUSED')
        Else
            WinSetTitle($hGUI, '', 'GIF Animation')
        EndIf
    Else
        HotKeySet("{PAUSE}")
        Send("{PAUSE}")
        HotKeySet("{PAUSE}", "Pause")
    EndIf
EndFunc

 

Edited by Zedna
Link to post
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Skysnake
      Good morning
       
      In terms of AutoIt, what is that? A GUI with an input control?
      How would that be coded?
      I have never done anything like this.
    • By XGamerGuide
      👋 Hey
      I want to call a function when something changes on an element in my GUI. That should work for a combo box (with $CBS_DROPDOWNLIST) when I select an item and for a text input when I type.
    • By NassauSky
      Hi all,
      The more projects I work on, the harder it is to find old scripts I created with certain techniques in them. I'd like to leave this here for others to get an idea from and it will be available now by keyword searching in this forum.
      This project needed an evenly distributed button grid setup on a touch screen with half decent sized buttons and spacing so the user would be less likely to press the key beside it. Here is one quick example to give anyone an idea of a way to handle it.
      #include <GUIConstants.au3> GUICreate("Button Grid", 1080, 100) ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box ;--Create and Position Controls Dim $btnActivated[1][2] ;Col 1 is button id, Col 2 is True/False used in 1 example as depressed Dim $btnArray[100][2] ;Col 1 is button id, Col 2 is True/False used in 1 example as depressed $num = 0 $btnActivated[0][0] = GUICtrlCreateButton("Activated", 0, 0, 100, 100) ;x,y,w,h $btnActivated[0][1] = True GUICtrlSetBkColor(-1,0x00ff00) GUICtrlSetColor(-1,0x005500) GUICtrlSetFont(-1,14) For $Y = 0 To 1 For $X = 0 To 7 ConsoleWrite( ($X * 100) + ($X*20) + 120 & @CRLF) If $Y=0 Then $btnArray[$num][0] = GUICtrlCreateButton($num + 1, ($X * 100) + ($X*20) + 120, 0, 100, 40) ;x,y,w,h Else $btnArray[$num][0] = GUICtrlCreateButton($num + 1, ($X * 100) + ($X*20) + 120, ($Y * 40) + $Y*20, 100, 40) ;x,y,w,h EndIf GUICtrlSetBkColor($btnArray[$num][0], 0xFFFFFF) $num += 1 Next Next ;--Set Button Names GUICtrlSetData($btnArray[0][0],"Autoit") GUICtrlSetData($btnArray[1][0],"Is") GUICtrlSetData($btnArray[2][0],"Cool") ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $btnActivated[0][0] $btnActivated[0][1] = NOT $btnActivated[0][1] If $btnActivated[0][1] Then GUICtrlSetBkColor($btnActivated[0][0],0x00ff00) GUICtrlSetColor($btnActivated[0][0],0x005500) GUICtrlSetData($btnActivated[0][0],"Activated") GUICtrlSetFont($btnActivated[0][0],14) Else GUICtrlSetBkColor($btnActivated[0][0],0xFF9999) GUICtrlSetColor($btnActivated[0][0],0x550000) GUICtrlSetData($btnActivated[0][0],"DeActivated") GUICtrlSetFont($btnActivated[0][0],13) EndIf Case $btnArray[0][0] If $btnActivated[0][1] Then MsgBox(0,"Notice","Btn1",1) EndIf Case $btnArray[1][0] If $btnActivated[0][1] Then MsgBox(0,"Notice","Btn2",1) EndIf Case $btnArray[2][0] If $btnActivated[0][1] Then MsgBox(0,"Notice","Btn3",1) EndIf EndSwitch WEnd I couldn't find one of my old projects that broke the button array into more columns that included the actual button name in the field. Feel free to share your own or share a more flexible version of this simple example.

    • By It_is_me_Me
      I am making some GUI with combobox for the Baudrates communications and I listed 9600, 57600, 115200. 
      I wrote the code to be defaulted to 57600 like this:
      GUICtrlSetData($comboBox_opticalBaudRate, "9600|57600|115200", "57600")
      But I wanted the GUI to remember the last item the user picks so the baudrates will NOT be defaulted to 57600.
      Example, I pick 9600 as my baudrates, then I close the GUI, after opening it, it always prompt 57600 since that is what I did in my code. But I want that if I choose 9600 and close the GUI, opening it again will show 9600 now instead of 57600.
      Is there a way to do it in GUI setting?
       
      Thanks.
    • By ashraful089
      #include <ButtonConstants.au3>
      #include <ComboConstants.au3>
      #include <GUIConstantsEx.au3>
      #include <WindowsConstants.au3>
      #Region ### START Koda GUI section ### Form=C:\Users\Engr. Ashraful\Videos\koda_1.7.3.0\Forms\ProgramPlayer\FormProgamToOpen.kxf
      $FormInput = GUICreate("Input", 302, 205, 454, 285)
      $Resolution = GUICtrlCreateCombo("Resolution", 80, 24, 145, 25)
      GUICtrlSetData(-1, "1920|VM1920|1366")
      $ComboProgramType = GUICtrlCreateCombo("Program Type Selection", 80, 64, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
      GUICtrlSetData(-1, "Multimedia|Official|Design|Web")
      $ButtonEnter = GUICtrlCreateButton("Enter", 104, 104, 75, 25)
      GUISetState(@SW_SHOW)
      #EndRegion ### END Koda GUI section ###
      While 1
          $nMsg = GUIGetMsg()
          Switch $nMsg
              Case $GUI_EVENT_CLOSE
                  Exit
          EndSwitch
      WEnd
       
      please help me to read combo box input and use the value for another function/ work
       
×
×
  • Create New...