La solution est de vérifier le timer dans la boucle principale et non dans une boucle secondaire.
Code : Tout sélectionner
#include <GUIConstants.au3>
#include <Constants.au3>
#include "Cached GIF Animation.au3"
#include <WinAPISysWin.au3>
Global $hGUI = GUICreate("GIF Animation", 500, 500, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0xFFFFFF)
Global $IMG_Ctrl1 = _GUICtrlCreateAnimGIF("9.gif", 150, 0, 192, 172, -1, $GUI_WS_EX_PARENTDRAG)
Global $IMG_Ctrl2 = _GUICtrlCreateAnimGIF("gif-Green-UFO.gif", 0, 180, 150, 80, -1, $GUI_WS_EX_PARENTDRAG)
Global $IMG_Ctrl3 = _GUICtrlCreateAnimGIF("Catalog.gif", 160, 180, 320, 184, -1, $GUI_WS_EX_PARENTDRAG)
Global $IMG_Ctrl4 = _GUICtrlCreateAnimGIF("Kafu.gif", 30, 260, 90, 90, -1, $GUI_WS_EX_PARENTDRAG)
Global $idButton = GUICtrlCreateButton("Show", 10, 10, 80, 30)
Global $idQuit = GUICtrlCreateButton("Quit", 10, 50, 80, 30)
Global $idAdlib = GUICtrlCreateButton("Adlib", 10, 90, 80, 30)
_WinAPI_SetLayeredWindowAttributes($hGUI, 0xFFFFFF)
GUISetState(@SW_SHOW, $hGUI)
GUICtrlSetState($IMG_Ctrl2, $GUI_HIDE) ; l'image est cachée au départ
Global $aCaption[4] = ["Show", "Delete", "Recreate", "Hide"], $iCounter = 0
Global $hTimer, $bRun = False
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $idQuit
ExitApp()
Case $idButton
Button()
Case $idAdlib
If $bRun Then ContinueLoop
$bRun = True
GUICtrlSetState($IMG_Ctrl2, $GUI_SHOW)
$hTimer = TimerInit()
EndSwitch
If $bRun And TimerDiff($hTimer) > 1500 Then
GUICtrlSetState($IMG_Ctrl2, $GUI_HIDE)
$bRun = False
EndIf
WEnd
Func Button()
$iCounter += 1
$iCounter = Mod($iCounter, 4)
GUICtrlSetData($idButton, $aCaption[$iCounter])
Switch $iCounter
Case 0 ; hide
GUICtrlSetState($IMG_Ctrl2, $GUI_HIDE)
Case 1 ; show
GUICtrlSetState($IMG_Ctrl2, $GUI_SHOW)
Case 2 ; delete
_GUICtrlDeleteAnimGIF($IMG_Ctrl2)
Case 3 ; recreate
$IMG_Ctrl2 = _GUICtrlCreateAnimGIF("gif-Green-UFO.gif", 0, 180, 150, 80, -1, $GUI_WS_EX_PARENTDRAG)
_WinAPI_SetLayeredWindowAttributes($hGUI, 0xFFFFFF)
EndSwitch
EndFunc ;==>Button
Func ExitApp()
_GIF_Animation_Quit()
Exit
EndFunc ;==>ExitApp
ps. j'ai converti en non-event par simplification de code