<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Воспроизведение AVI в окне GUI]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=1653&amp;type=atom" />
	<updated>2008-06-25T10:54:06Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=1653</id>
		<entry>
			<title type="html"><![CDATA[AHK: Воспроизведение AVI в окне GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=11788#p11788" />
			<content type="html"><![CDATA[<p>Нарыл на буржуйском форуме скрипт для воспроизведения AVI в окне GUI, немножко его переделал и получилось вот что:<br /></p><div class="codebox"><pre><code>AVI_CreateControl(_guiHwnd, _x, _y, _w, _h, _aviRef, _aviDLL=&quot;&quot;, _style=&quot;&quot;)
{
    local aviHwnd, aviInstance, style
    local msg, r, c
    msg = Создание &#039;%_aviRef%&#039; AVI нарушено:
    If (_aviDLL = &quot;&quot;)
        _aviDLL = Shell32.dll    ; Lot of standard AVIs in there
    If _aviRef is digit
    {
        aviInstance := DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, _aviDLL)
        If (aviInstance = 0)
        {
            msg = %msg% Не загружается &#039;%_aviDLL%&#039; DLL
            Return msg
        }
    }
    style := 0
    If (_style != &quot;&quot;)
    {
        If _style contains transparent
            style |= 2    ; ACS_TRANSPARENT
        If _style contains center
            style |= 1    ; ACS_CENTER
        If _style contains autoplay
            style |= 4    ; ACS_AUTOPLAY
        If _style contains all    ; Simpler defaut...
            style |= 7
    }
    ; WS_CHILD | WS_VISIBLE
    style := 0x50000000 | style
    aviHwnd := DLLCall(&quot;CreateWindowEx&quot;
            , &quot;UInt&quot;, 0             ; Style
            , &quot;Str&quot;, &quot;SysAnimate32&quot; ; Class Name
            , &quot;UInt&quot;, 0             ; Window name
            , &quot;UInt&quot;, style         ; Window style
            , &quot;Int&quot;, _x             ; X position
            , &quot;Int&quot;, _y             ; Y position
            , &quot;Int&quot;, _w             ; Width
            , &quot;Int&quot;, _h             ; Height
            , &quot;UInt&quot;, _guiHwnd      ; Handle of parent
            , &quot;UInt&quot;, 0             ; Menu
            , &quot;UInt&quot;, 0             ; hInstance, unneeded with User32 components
            , &quot;UInt&quot;, 0)            ; User defined style
    If (ErrorLevel != 0 or aviHwnd = 0)
    {
        msg = %msg% AVI control не создан (%ErrorLevel%/%A_LastError%)
        Gosub AVI_CreateControl_CleanUp
        Return msg
    }
    If _aviRef is digit
    {
        SendMessage 1124, aviInstance, _aviRef, , ahk_id %aviHwnd%
    }
    Else
    {
        SendMessage 1124, 0, &amp;_aviRef, , ahk_id %aviHwnd%
    }
    If (ErrorLevel = &quot;FAIL&quot; or ErrorLevel = 0)
    {
        msg = %msg% Не удалось открыть AVI (%ErrorLevel%)
        Gosub AVI_CreateControl_CleanUp
        Return msg
    }

    Return aviHwnd

AVI_CreateControl_CleanUp:    ; Ничего не делать в случае ошибки
Return
}

; WM_USER := 0x400 ; 1024

;Старт или продолжение воспроизведения
AVI_Play(_aviHwnd)
{
    ; wParam: Число раз проигрывания видео. При -1 проигрывается бесконечно
    ; lParam: MAKELONG(wFrom, wTo)
    ;   wFrom: Нулевое положение фрейма, откуда начать воспроизведение. Должна быть менее 65,536.
    ;     Если 0, то начинает с первого фрейма.
    ;   wTo: Нулевое положение фрейма, где надо закончить воспроизведение.
    ;     Должна быть менее 65,536. Если -1, заканчивает последним фреймом AVI клипа.
    ; ACM_PLAY := WM_USER + 101
    PostMessage 1125, 1, -1, , ahk_id %_aviHwnd%
}

AVI_Play_Cycle(_aviHwnd)
{
    PostMessage 1125, -1, -1, , ahk_id %_aviHwnd%
}

;Остановка или пауза воспроизведения
AVI_Stop(_aviHwnd)
{
    ; ACM_STOP := WM_USER + 102
    PostMessage 1126, 0, 0, , ahk_id %_aviHwnd%
}

; Вероятно дополнительный, автоматически на закрытии сценария
AVI_DestroyControl(_aviHwnd)
{
    If (_aviHwnd != 0)
        DllCall(&quot;DestroyWindow&quot;, &quot;UInt&quot;, _aviHwnd)
}


AVI_Shell32 =
( Join|
000 - File
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
)
AVI_MSGina = 2413 - Ctrl+Alt+Delete
AVI_SyncUI = 133 - Sync|134 - Compare
AVI_WIADefUI =
( Join|
1000 - Camera connect
1001 - Scanner connect
1002 - Camcorder connect
1003 - Camcorder copy
1004 - Scanner copy
1005 - Camera copy
1006 - Camera and scanner connect
)
AVI_XPSP2 = 140 - Search flashlight|160 - Network connect

Gui +LastFound
guiID := WinExist()

width := 300

;h1 := AVI_CreateControl(guiID, 20, 10, width, 130, A_ScriptDir . &quot;\Eject.avi&quot;)
;If h1 is not integer
;    MsgBox %h1%
Gui Add, Button, x10 y450 w50 v11 gControl_AVI_Control, Start
Gui Add, Button, x70 yp w50 gControl_AVI_Cicle, Cicle
Gui Add, Button, x130 yp w50 v01 gControl_AVI_Control, Stop
Gui Add, Button, x190 yp w50 gControl_AVI_Exit, End
Gui Add, Button, x250 yp w50 gControl_AVI_Select, Select
Gui Show, w560, AVI Demo
Return

Control_AVI_Control:
    StringLeft action, A_GuiControl, 1
    StringRight control, A_GuiControl, 1
    If (action = 1)
        AVI_Play(h%control%)
    Else If (action = 0)
        AVI_Stop(h%control%)
Return

Control_AVI_Cicle:
AVI_Play_Cycle(h%control%)
Return

GuiClose:
Control_AVI_Exit:
ExitApp

Guidropfiles:
AVIfile= %A_GuiEvent%
goto SelectFile

Control_AVI_Select:
AVIfile=
FileSelectFile,AVIfile,1,,Выбрать AVI,*.avi
if AVIfile=
Return
if errorlevel= 1
Return
SelectFile:
ControlGet,aviHwnd,Hwnd,,SysAnimate321,AVI Demo
h1 := AVI_DestroyControl(aviHwnd)
h1 := AVI_CreateControl(guiID, 20, 10, width, 130, AVIfile)
If h1 is not integer
    MsgBox %h1%
Return</code></pre></div><p>Такой скрипт может отображать AVI только определенного вида, те, которые обычно использует система. Например, как тот, что приложен в архиве.<br />Если кто в состоянии настроить его на воспроизведение и других AVI, создайте ветку в разделе &quot;Разработка&quot;.</p>]]></content>
			<author>
				<name><![CDATA[pant-79]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=960</uri>
			</author>
			<updated>2008-06-25T10:54:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=11788#p11788</id>
		</entry>
</feed>
