Edit: In the meantime, PhiLho provided a library:
CreateWindow_AVI.ahk for ease of use, check it out.
With this code, you can add an animated AVI to your AHK Gui. It loads the AVI's from resource into a SysAnimate32 control, in this example I used the built-in Shell32.dll.
This script was tested on Windows XP SP2.
Code:
; Add an animation control to your AHK Gui
;
; http://windowssdk.msdn.microsoft.com/en-us/library/ms673600.aspx
AniList =
(LTrim Join|
150 - Search flashlight
151 - Search documents
152 - Search computer
160 - Move files
161 - Copy files
162 - Delete files
163 - Empty trash
164 - Empty folder
165 - Check files
166 - Search internet
167 - Move files
168 - Copy files
169 - Empty folder
170 - Download files
)
Gui, 1: Add, GroupBox, x10 y10 w160 h230, Available avi's:
Gui, 1: Add, ListBox, x20 y30 w140 h200 vAniChoiceVar gAniChoice Choose1 AltSubmit, %AniList%
Gui, 1: Add, GroupBox, x180 y10 w410 h230, Preview:
Gui, 1: Add, Button, x190 y210 w120 gStartAni, Start animation
Gui, 1: Add, Button, x340 y210 w120 gStopAni, Stop animation
Gui, 1: Show, w600 h250, Add built-in AVI Animation to AHK GUI - Windows XP - shell32.dll avi's
WinGet, mainGuiHandle, ID, A
; Load shell32.dll
aniInstance := GuiAddResAniInit("Shell32.dll")
autoRun = 1
GoSub, AniChoice
Return
StartAni:
; http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/animation/messages/acm_play.asp
; wParam: Number of times to replay the AVI clip. A value of -1 means replay the clip indefinitely.
; lParam: MAKELONG(wFrom, wTo)
; wFrom: Zero-based index of the frame where playing begins. The value must be less than 65,536.
; A value of zero means begin with the first frame in the AVI clip.
; wTo: Zero-based index of the frame where playing ends.
; The value must be less than 65,536. A value of -1 means end with the last frame in the AVI clip.
PostMessage, %ACM_PLAY%, -1, -1, , ahk_id %aniCtlHandle%
Return
StopAni:
; http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/animation/messages/acm_stop.asp
PostMessage, %ACM_STOP%, 0, 0, , ahk_id %aniCtlHandle%
Return
; Animation selected
AniChoice:
If (A_GuiControlEvent = "Normal" or autoRun = 1 )
{
Gui, Submit, NoHide
; Get aniNr - thanks PhiLho
Loop Parse, AniList, |
{
If (A_Index = AniChoiceVar)
StringLeft aniNr, A_LoopField, 3
}
; Autorun
If aniNr =
{
aniNr = 150
autoRun = 0
}
; Remove existing
If aniCtlHandle !=
DLLCall("DestroyWindow", uint, aniCtlHandle)
; Add control
posx = 220
posy = 60
posw = 300
posh = 80
GuiAddResAni(mainGuiHandle, aniInstance, aniNr, posx, posy, posw, posh)
}
Return
GuiAddResAniInit(pathToDLL)
{
Return DLLCall("LoadLibrary", str, pathToDLL)
}
GuiAddResAni(mainGuiHandle, aniInstance, aniNr, posx, posy, posw, posh)
{
global aniCtlHandle, ACM_PLAY, ACM_STOP
NULL =
WS_CHILD = 0x40000000
WS_VISIBLE = 0x10000000
ACS_AUTOPLAY = 0x0004
ACS_TRANSPARENT = 0x0002
ACS_CENTER = 0x0001
ACM_OPEN := 0x400 + 100
ACM_PLAY := 0x400 + 101
ACM_STOP := 0x400 + 102
aniCtlHandle := DLLCall("CreateWindowEx"
, uint, 0 ; Style
, str, "SysAnimate32" ; Class Name
, str, NULL ; Window name
, uint, WS_CHILD|WS_VISIBLE|ACS_TRANSPARENT|ACS_CENTER|ACS_AUTOPLAY ; window style
, int, posx ; Left
, int, posy ; Top
, int, posw ; Right
, int, posh ; Bottom
, uint, mainGuiHandle ; Handle of parent
, int, NULL ; Menu
, uint, aniInstance ; hInstance
, string, NULL) ; User defined style
; http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/animation/messages/acm_open.asp
; wParam: Instance handle to the module from which the resource should be loaded.
; Note that if the window is created by a DLL, the default value for hinst is the HINSTANCE value of the DLL, not of the application that calls the DLL.
; lParam: Pointer to a buffer that contains the path of the AVI file or the name of an AVI resource.
; Alternatively, this parameter can consist of the AVI resource identifier in the low-order word and zero in the high-order word.
PostMessage, %ACM_OPEN%, %aniInstance%, %aniNr%, , ahk_id %aniCtlHandle%
}
GuiAddResAniRemove()
{
DllCall("FreeLibrary", "uint", aniInstance)
}
GuiClose:
GuiEscape:
GuiAddResAniRemove()
ExitApp
Edit: In the meantime, PhiLho provided a library:
CreateWindow_AVI.ahk for ease of use, check it out.
Edit: Added link to CreateWindow_AVI.ahk library by PhiLho
Edit: Updated code: Added AutoRun, and single click ListView selection. Replaced if-tree with PhiLho's parsing loop, thanks!
Edit: Updated code with PhiLho's corrected PostMessages