<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Запись mp3 с подрезкой тишины]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=17666&amp;type=atom" />
	<updated>2023-03-12T03:08:18Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=17666</id>
		<entry>
			<title type="html"><![CDATA[AHK: Запись mp3 с подрезкой тишины]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=157103#p157103" />
			<content type="html"><![CDATA[<p>Понадобилось для одного проекта записывать звук с подрезкой тишины с начала и с конца.<br />Написал гуи для ffmpeg.<br /><a href="https://www.videohelp.com/software/ffmpeg">https://www.videohelp.com/software/ffmpeg</a><br />ffmpeg.exe нужно будет переименовать в ffmpeg_script.exe.<br />Скрипт создает temp.wav, который потом стирает.<br />Результат сохраняется в %A_Now%.mp3.<br /></p><div class="codebox"><pre><code>NoiseGate := -70

#SingleInstance force
OnExit, MP3RecordGuiClose

LOAD_DLL_Mf_Mfplat()
MFStartup(version := 2, MFSTARTUP_FULL := 0)
MFCreateAttributes(pMFAttributes, 1)
IMFAttributes_SetGUID(pMFAttributes, MF_GUID(GUID, &quot;MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE&quot;), MF_GUID(GUID1, &quot;MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_GUID&quot;))
MFEnumDeviceSources(pMFAttributes, pppSourceActivate, pcSourceActivate)
Loop % pcSourceActivate
{
   IMFActivate := NumGet(pppSourceActivate + (A_Index - 1)*A_PtrSize)
   name := IMFActivate_GetAllocatedString(IMFActivate, MF_GUID(GUID, &quot;MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME&quot;))
   if (A_Index = 1)
      RecordingDevices .= name &quot;||&quot;
   else
      RecordingDevices .= name &quot;|&quot;
   ObjRelease(IMFActivate)
}
DllCall(&quot;ole32\CoTaskMemFree&quot;, &quot;ptr&quot;, pppSourceActivate)
ObjRelease(pMFAttributes)
MFShutdown()
UNLOAD_DLL_Mf_Mfplat()

Gui, MP3Record: +AlwaysOnTop -DpiScale
Gui, MP3Record: Add, Text, x12, RecordingDevice:
Gui, MP3Record: Add, DDL, vRecordingDevice x12 w250, % RecordingDevices
Gui, MP3Record: Add, Button, x12 y62 w120 h20 vRecord gMP3Record, Start Recording
Gui, MP3Record: Add, Text, x54 y86 w80 vMP3Time
Gui, MP3Record: Show
return

MP3Record:
GuiControlGet, RecordingDevice
if (CurrentState != &quot;Record&quot;)
{
   loop
   {
      Process, Exist, ffmpeg_script.exe
      if ErrorLevel
      {
         Process, Close, ffmpeg_script.exe
         Process, WaitClose, ffmpeg_script.exe
      }
      else
         break
   }
   Run, ffmpeg_script.exe -f dshow -i audio=&quot;%RecordingDevice%&quot; -acodec copy -y temp.wav, , hide, pid
   loop
   {
      if DllCall(&quot;AttachConsole&quot;, &quot;uint&quot;, pid)
         break
      sleep 10
   }
   hConIn := DllCall(&quot;CreateFile&quot;, &quot;str&quot;, &quot;CONIN$&quot;, &quot;uint&quot;, 0xC0000000, &quot;uint&quot;, 0x3, &quot;uint&quot;, 0, &quot;uint&quot;, 0x3, &quot;uint&quot;, 0, &quot;uint&quot;, 0, &quot;ptr&quot;)
   if (hConIn = -1)
   {
      msgbox error CreateFile %A_LastError%
      ExitApp
   }
   VarSetCapacity(ir, 24, 0)       ; ir := new INPUT_RECORD
   NumPut(1, ir, 0, &quot;UShort&quot;)      ; ir.EventType := KEY_EVENT
   NumPut(1, ir, 8, &quot;UShort&quot;)      ; ir.KeyEvent.wRepeatCount := 1
   min := sec := 0
   CurrentState := &quot;Record&quot;
   GuiControl,, Record, Stop Recording
   SetTimer, Count, 1000
}
else
{
   CurrentState := &quot;&quot;
   GuiControl,, Record, Start Recording
   SetTimer, Count, Off
   NumPut(Asc(&quot;q&quot;), ir, 14, &quot;UShort&quot;)
   NumPut(true, ir, 4, &quot;Int&quot;)  ; ir.KeyEvent.bKeyDown := true
   if !DllCall(&quot;WriteConsoleInput&quot;, &quot;ptr&quot;, hConIn, &quot;ptr&quot;, &amp;ir, &quot;uint&quot;, 1, &quot;uint*&quot;, 0)
   {
      msgbox error WriteConsoleInput one %A_LastError%
      ExitApp
   }
   NumPut(false, ir, 4, &quot;Int&quot;) ; ir.KeyEvent.bKeyDown := false
   if !DllCall(&quot;WriteConsoleInput&quot;, &quot;ptr&quot;, hConIn, &quot;ptr&quot;, &amp;ir, &quot;uint&quot;, 1, &quot;uint*&quot;, 0)
   {
      msgbox error WriteConsoleInput two %A_LastError%
      ExitApp
   }
   DllCall(&quot;CloseHandle&quot;, &quot;ptr&quot;, hConIn)
   hConIn := &quot;&quot;
   DllCall(&quot;FreeConsole&quot;)
   Process, WaitClose, ffmpeg_script.exe
   MsgBox, 274340,, Save recorded mp3?
   IfMsgBox Yes
   {
      Run, ffmpeg_script.exe -i temp.wav -ab 320k -acodec libmp3lame -y -af &quot;silenceremove=start_periods=1:start_duration=0:start_threshold=%NoiseGate%dB`,areverse`,silenceremove=start_periods=1:start_duration=0:start_threshold=%NoiseGate%dB`,areverse&quot; &quot;%A_Now%.mp3&quot;, , hide
      Process, WaitClose, ffmpeg_script.exe
   }
   GuiControl,, MP3Time
   FileDelete, temp.wav
}
return

Count:
sec++
if (sec = 60)
{
   min++
   sec := 0
}
GuiControl, MP3Record:, MP3Time, % &quot;0:&quot; Format(&quot;{1:02}&quot;, min) &quot;:&quot; Format(&quot;{1:02}&quot;, sec)
return

MP3RecordGuiClose:
loop
{
   Process, Exist, ffmpeg_script.exe
   if ErrorLevel
   {
      Process, Close, ffmpeg_script.exe
      Process, WaitClose, ffmpeg_script.exe
   }
   else
      break
}
FileDelete, temp.wav
ExitApp


LOAD_DLL_Mf_Mfplat()
{
   if !DllCall(&quot;GetModuleHandle&quot;,&quot;str&quot;,&quot;Mf&quot;)
      DllCall(&quot;LoadLibrary&quot;,&quot;Str&quot;, &quot;Mf.dll&quot;, &quot;ptr&quot;)
   if !DllCall(&quot;GetModuleHandle&quot;,&quot;str&quot;,&quot;Mfplat&quot;)
      DllCall(&quot;LoadLibrary&quot;,&quot;Str&quot;, &quot;Mfplat.dll&quot;, &quot;ptr&quot;)
}

UNLOAD_DLL_Mf_Mfplat()
{
   if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, &quot;Mf&quot;, &quot;ptr&quot;)
      DllCall(&quot;FreeLibrary&quot;, &quot;ptr&quot;, hModule)
   if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, &quot;Mfplat&quot;, &quot;ptr&quot;)
      DllCall(&quot;FreeLibrary&quot;, &quot;ptr&quot;, hModule)
}

MFStartup(version, dwFlags)
{
   hr := DllCall(&quot;Mfplat.dll\MFStartup&quot;, &quot;uint&quot;, version, &quot;uint&quot;, dwFlags)
   if hr or ErrorLevel
      _Error(A_ThisFunc &quot; error: &quot; hr &quot;`nErrorLevel: &quot; ErrorLevel)
}

MFCreateAttributes(ByRef ppMFAttributes, cInitialSize)
{
   hr := DllCall(&quot;Mfplat.dll\MFCreateAttributes&quot;, &quot;ptr*&quot;, ppMFAttributes, &quot;uint&quot;, cInitialSize)
   if hr or ErrorLevel
      _Error(A_ThisFunc &quot; error: &quot; hr &quot;`nErrorLevel: &quot; ErrorLevel)
}

IMFAttributes_SetGUID(this, guidKey, guidValue)
{
   hr := DllCall(NumGet(NumGet(this+0)+24*A_PtrSize), &quot;ptr&quot;, this, &quot;ptr&quot;, guidKey, &quot;ptr&quot;, guidValue)
   if hr or ErrorLevel
      _Error(A_ThisFunc &quot; error: &quot; hr &quot;`nErrorLevel: &quot; ErrorLevel)
}

MFEnumDeviceSources(pAttributes, ByRef pppSourceActivate, ByRef pcSourceActivate)
{
   hr := DllCall(&quot;Mf.dll\MFEnumDeviceSources&quot;, &quot;ptr&quot;, pAttributes, &quot;ptr*&quot;, pppSourceActivate, &quot;uint*&quot;, pcSourceActivate)
   if hr or ErrorLevel
      _Error(A_ThisFunc &quot; error: &quot; hr &quot;`nErrorLevel: &quot; ErrorLevel)
}

IMFActivate_GetAllocatedString(this, guidKey)
{
   hr := DllCall(NumGet(NumGet(this+0)+13*A_PtrSize), &quot;ptr&quot;, this, &quot;ptr&quot;, guidKey, &quot;ptr*&quot;, ppwszValue, &quot;uint*&quot;, pcchLength)
   if hr or ErrorLevel
      _Error(A_ThisFunc &quot; error: &quot; hr &quot;`nErrorLevel: &quot; ErrorLevel)
   AllocatedString := StrGet(ppwszValue, pcchLength, &quot;UTF-16&quot;)
   DllCall(&quot;ole32\CoTaskMemFree&quot;, &quot;ptr&quot;, ppwszValue)
   return AllocatedString
}

MF_GUID(ByRef GUID, name)
{
   static init:=1, _:={}
   if init
   {
      init:=0
      _.MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE := [0xc60ac5fe, 0x252a, 0x478f, 0xa0, 0xef, 0xbc, 0x8f, 0xa5, 0xf7, 0xca, 0xd3]
      _.MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_GUID := [0x14dd9a1c, 0x7cff, 0x41be, 0xb1, 0xb9, 0xba, 0x1a, 0xc6, 0xec, 0xb5, 0x71]
      _.MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME := [0x60d0e559, 0x52f8, 0x4fa2, 0xbb, 0xce, 0xac, 0xdb, 0x34, 0xa8, 0xec, 0x1]
   }
   if _.haskey(name)
   {
      p := _[name]
      VarSetCapacity(GUID,16)
      ,NumPut(p.1+(p.2&lt;&lt;32)+(p.3&lt;&lt;48),GUID,0,&quot;int64&quot;)
      ,NumPut(p.4+(p.5&lt;&lt;8)+(p.6&lt;&lt;16)+(p.7&lt;&lt;24)+(p.8&lt;&lt;32)+(p.9&lt;&lt;40)+(p.10&lt;&lt;48)+(p.11&lt;&lt;56),GUID,8,&quot;int64&quot;)
      return &amp;GUID
   }
   else return name
}

_Error(val)
{
   msgbox % val
   ExitApp
}

MFShutdown()
{
   hr := DllCall(&quot;Mfplat.dll\MFShutdown&quot;)
   if hr or ErrorLevel
      _Error(A_ThisFunc &quot; error: &quot; hr &quot;`nErrorLevel: &quot; ErrorLevel)
}</code></pre></div><p>Пример записи звука с внешнего источника с автоостопом при возникновении тишины меньшей чем -70дб, длящейся более 2 секунд.<br /></p><div class="codebox"><pre><code>SilenceDuration := 2000
NoiseGate := -70

#SingleInstance force
OnExit, MP3RecordGuiClose

LOAD_DLL_Mf_Mfplat()
MFStartup(version := 2, MFSTARTUP_FULL := 0)
MFCreateAttributes(pMFAttributes, 1)
IMFAttributes_SetGUID(pMFAttributes, MF_GUID(GUID, &quot;MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE&quot;), MF_GUID(GUID1, &quot;MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_GUID&quot;))
MFEnumDeviceSources(pMFAttributes, pppSourceActivate, pcSourceActivate)
Loop % pcSourceActivate
{
   IMFActivate := NumGet(pppSourceActivate + (A_Index - 1)*A_PtrSize)
   name := IMFActivate_GetAllocatedString(IMFActivate, MF_GUID(GUID, &quot;MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME&quot;))
   if (A_Index = 1)
      RecordingDevices .= name &quot;||&quot;
   else
      RecordingDevices .= name &quot;|&quot;
   ObjRelease(IMFActivate)
}
DllCall(&quot;ole32\CoTaskMemFree&quot;, &quot;ptr&quot;, pppSourceActivate)
ObjRelease(pMFAttributes)
MFShutdown()
UNLOAD_DLL_Mf_Mfplat()

Gui, MP3Record: +AlwaysOnTop -DpiScale
Gui, MP3Record: Add, Text, x12, RecordingDevice:
Gui, MP3Record: Add, DDL, vRecordingDevice x12 w250, % RecordingDevices
Gui, MP3Record: Add, Button, x12 y62 w120 h20 vRecord gMP3Record, Start Recording
Gui, MP3Record: Add, Text, x54 y86 w80 vMP3Time
Gui, MP3Record: Show
return

MP3Record:
GuiControlGet, RecordingDevice
loop
{
   Process, Exist, ffmpeg_script.exe
   if ErrorLevel
   {
      Process, Close, ffmpeg_script.exe
      Process, WaitClose, ffmpeg_script.exe
   }
   else
      break
}
Run, ffmpeg_script.exe -f dshow -i audio=&quot;%RecordingDevice%&quot; -af silencedetect=noise=%NoiseGate%dB:d=0.1 -y temp.wav, , hide, pid
loop
{
   if DllCall(&quot;AttachConsole&quot;, &quot;uint&quot;, pid)
      break
   sleep 10
}
min := sec := 0
GuiControl, Disable, Record
SetTimer, Count, 1000
hConOut := DllCall(&quot;CreateFile&quot;, &quot;str&quot;, &quot;CONOUT$&quot;, &quot;uint&quot;, 0xC0000000, &quot;uint&quot;, 0x3, &quot;ptr&quot;, 0, &quot;uint&quot;, 0x3, &quot;uint&quot;, 0, &quot;ptr&quot;, 0, &quot;ptr&quot;)
if (hConOut = -1)
{
   msgbox error CreateFile CONOUT %A_LastError%
   ExitApp
}
loop
{
   VarSetCapacity(ConsoleScreenBufferInfo, 24, 0)
   if !DllCall(&quot;GetConsoleScreenBufferInfo&quot;, &quot;ptr&quot;, hConOut, &quot;ptr&quot;, &amp;ConsoleScreenBufferInfo)
   {
      msgbox GetConsoleScreenBufferInfo failed - error %A_LastError%
      ExitApp
   }
   ConWinHeight := NumGet(ConsoleScreenBufferInfo, 6, &quot;Short&quot;) + 1
   if (ConWinHeight = 0)
      ConWinHeight := NumGet(ConsoleScreenBufferInfo, 20, &quot;Short&quot;) + 1
   if !ConWinWidth
      ConWinWidth := NumGet(ConsoleScreenBufferInfo, 18, &quot;Short&quot;) + 1
   VarSetCapacity(ConsoleText, ConWinWidth*ConWinHeight*2, 0)
   if !DllCall(&quot;ReadConsoleOutputCharacter&quot;, &quot;ptr&quot;, hConOut, &quot;str&quot;, ConsoleText, &quot;uint&quot;, ConWinWidth*ConWinHeight, &quot;uint&quot;, 0, &quot;ptr*&quot;, numCharsRead)
   {
      msgbox ReadConsoleOutputCharacter failed - error %A_LastError%.
      ExitApp
   }
   if !RecordingStart and InStr(ConsoleText, &quot;time=00:&quot;)
      RecordingStart := 1
   if RecordingStart and !RecordingStartSound and (!InStr(ConsoleText, &quot;silence_start:&quot;) or InStr(ConsoleText, &quot;silence_end:&quot;))
      RecordingStartSound := 1
   if RecordingStartSound
   {
      StrReplace(ConsoleText, &quot;silence_start:&quot;, &quot;silence_start:&quot;, silence_startCount)
      StrReplace(ConsoleText, &quot;silence_end:&quot;, &quot;silence_end:&quot;, silence_endCount)
      if (silence_startCount &gt; silence_endCount)
      {
         if !SilenceTime
            SilenceTime := A_TickCount
         else if ((A_TickCount - SilenceTime) &gt; SilenceDuration)
         {
            RecordingStart := RecordingStartSound := SilenceTime := ConWinWidth := &quot;&quot;
            DllCall(&quot;CloseHandle&quot;, &quot;ptr&quot;, hConOut)
            break
         }
      }
      else 
         SilenceTime := &quot;&quot;
   }
   sleep 10
}
hConIn := DllCall(&quot;CreateFile&quot;, &quot;str&quot;, &quot;CONIN$&quot;, &quot;uint&quot;, 0xC0000000, &quot;uint&quot;, 0x3, &quot;ptr&quot;, 0, &quot;uint&quot;, 0x3, &quot;uint&quot;, 0, &quot;ptr&quot;, 0, &quot;ptr&quot;)
if (hConIn = -1)
{
   msgbox error CreateFile CONIN %A_LastError%
   ExitApp
}
VarSetCapacity(ir, 24, 0)       ; ir := new INPUT_RECORD
NumPut(1, ir, 0, &quot;UShort&quot;)      ; ir.EventType := KEY_EVENT
NumPut(1, ir, 8, &quot;UShort&quot;)      ; ir.KeyEvent.wRepeatCount := 1
NumPut(Asc(&quot;q&quot;), ir, 14, &quot;UShort&quot;)
NumPut(true, ir, 4, &quot;Int&quot;)  ; ir.KeyEvent.bKeyDown := true
if !DllCall(&quot;WriteConsoleInput&quot;, &quot;ptr&quot;, hConIn, &quot;ptr&quot;, &amp;ir, &quot;uint&quot;, 1, &quot;uint*&quot;, 0)
{
   msgbox error WriteConsoleInput one %A_LastError%
   ExitApp
}
NumPut(false, ir, 4, &quot;Int&quot;) ; ir.KeyEvent.bKeyDown := false
if !DllCall(&quot;WriteConsoleInput&quot;, &quot;ptr&quot;, hConIn, &quot;ptr&quot;, &amp;ir, &quot;uint&quot;, 1, &quot;uint*&quot;, 0)
{
   msgbox error WriteConsoleInput two %A_LastError%
   ExitApp
}
DllCall(&quot;CloseHandle&quot;, &quot;ptr&quot;, hConIn)
DllCall(&quot;FreeConsole&quot;)
SetTimer, Count, Off
GuiControl,, MP3Time
Process, WaitClose, ffmpeg_script.exe
Run, ffmpeg_script.exe -i temp.wav -ab 320k -acodec libmp3lame -y -af &quot;silenceremove=start_periods=1:start_duration=0:start_threshold=%NoiseGate%dB`,areverse`,silenceremove=start_periods=1:start_duration=0:start_threshold=%NoiseGate%dB`,areverse&quot; &quot;%A_Now%.mp3&quot;, , hide
Process, WaitClose, ffmpeg_script.exe
FileDelete, temp.wav
msgbox done
GuiControl, Enable, Record
return


Count:
sec++
if (sec = 60)
{
   min++
   sec := 0
}
GuiControl, MP3Record:, MP3Time, % &quot;0:&quot; Format(&quot;{1:02}&quot;, min) &quot;:&quot; Format(&quot;{1:02}&quot;, sec)
return

MP3RecordGuiClose:
loop
{
   Process, Exist, ffmpeg_script.exe
   if ErrorLevel
   {
      Process, Close, ffmpeg_script.exe
      Process, WaitClose, ffmpeg_script.exe
   }
   else
      break
}
FileDelete, temp.wav
ExitApp


LOAD_DLL_Mf_Mfplat()
{
   if !DllCall(&quot;GetModuleHandle&quot;,&quot;str&quot;,&quot;Mf&quot;)
      DllCall(&quot;LoadLibrary&quot;,&quot;Str&quot;, &quot;Mf.dll&quot;, &quot;ptr&quot;)
   if !DllCall(&quot;GetModuleHandle&quot;,&quot;str&quot;,&quot;Mfplat&quot;)
      DllCall(&quot;LoadLibrary&quot;,&quot;Str&quot;, &quot;Mfplat.dll&quot;, &quot;ptr&quot;)
}

UNLOAD_DLL_Mf_Mfplat()
{
   if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, &quot;Mf&quot;, &quot;ptr&quot;)
      DllCall(&quot;FreeLibrary&quot;, &quot;ptr&quot;, hModule)
   if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, &quot;Mfplat&quot;, &quot;ptr&quot;)
      DllCall(&quot;FreeLibrary&quot;, &quot;ptr&quot;, hModule)
}

MFStartup(version, dwFlags)
{
   hr := DllCall(&quot;Mfplat.dll\MFStartup&quot;, &quot;uint&quot;, version, &quot;uint&quot;, dwFlags)
   if hr or ErrorLevel
      _Error(A_ThisFunc &quot; error: &quot; hr &quot;`nErrorLevel: &quot; ErrorLevel)
}

MFCreateAttributes(ByRef ppMFAttributes, cInitialSize)
{
   hr := DllCall(&quot;Mfplat.dll\MFCreateAttributes&quot;, &quot;ptr*&quot;, ppMFAttributes, &quot;uint&quot;, cInitialSize)
   if hr or ErrorLevel
      _Error(A_ThisFunc &quot; error: &quot; hr &quot;`nErrorLevel: &quot; ErrorLevel)
}

IMFAttributes_SetGUID(this, guidKey, guidValue)
{
   hr := DllCall(NumGet(NumGet(this+0)+24*A_PtrSize), &quot;ptr&quot;, this, &quot;ptr&quot;, guidKey, &quot;ptr&quot;, guidValue)
   if hr or ErrorLevel
      _Error(A_ThisFunc &quot; error: &quot; hr &quot;`nErrorLevel: &quot; ErrorLevel)
}

MFEnumDeviceSources(pAttributes, ByRef pppSourceActivate, ByRef pcSourceActivate)
{
   hr := DllCall(&quot;Mf.dll\MFEnumDeviceSources&quot;, &quot;ptr&quot;, pAttributes, &quot;ptr*&quot;, pppSourceActivate, &quot;uint*&quot;, pcSourceActivate)
   if hr or ErrorLevel
      _Error(A_ThisFunc &quot; error: &quot; hr &quot;`nErrorLevel: &quot; ErrorLevel)
}

IMFActivate_GetAllocatedString(this, guidKey)
{
   hr := DllCall(NumGet(NumGet(this+0)+13*A_PtrSize), &quot;ptr&quot;, this, &quot;ptr&quot;, guidKey, &quot;ptr*&quot;, ppwszValue, &quot;uint*&quot;, pcchLength)
   if hr or ErrorLevel
      _Error(A_ThisFunc &quot; error: &quot; hr &quot;`nErrorLevel: &quot; ErrorLevel)
   AllocatedString := StrGet(ppwszValue, pcchLength, &quot;UTF-16&quot;)
   DllCall(&quot;ole32\CoTaskMemFree&quot;, &quot;ptr&quot;, ppwszValue)
   return AllocatedString
}

MF_GUID(ByRef GUID, name)
{
   static init:=1, _:={}
   if init
   {
      init:=0
      _.MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE := [0xc60ac5fe, 0x252a, 0x478f, 0xa0, 0xef, 0xbc, 0x8f, 0xa5, 0xf7, 0xca, 0xd3]
      _.MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_GUID := [0x14dd9a1c, 0x7cff, 0x41be, 0xb1, 0xb9, 0xba, 0x1a, 0xc6, 0xec, 0xb5, 0x71]
      _.MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME := [0x60d0e559, 0x52f8, 0x4fa2, 0xbb, 0xce, 0xac, 0xdb, 0x34, 0xa8, 0xec, 0x1]
   }
   if _.haskey(name)
   {
      p := _[name]
      VarSetCapacity(GUID,16)
      ,NumPut(p.1+(p.2&lt;&lt;32)+(p.3&lt;&lt;48),GUID,0,&quot;int64&quot;)
      ,NumPut(p.4+(p.5&lt;&lt;8)+(p.6&lt;&lt;16)+(p.7&lt;&lt;24)+(p.8&lt;&lt;32)+(p.9&lt;&lt;40)+(p.10&lt;&lt;48)+(p.11&lt;&lt;56),GUID,8,&quot;int64&quot;)
      return &amp;GUID
   }
   else return name
}

_Error(val)
{
   msgbox % val
   ExitApp
}

MFShutdown()
{
   hr := DllCall(&quot;Mfplat.dll\MFShutdown&quot;)
   if hr or ErrorLevel
      _Error(A_ThisFunc &quot; error: &quot; hr &quot;`nErrorLevel: &quot; ErrorLevel)
}</code></pre></div><p><a href="http://forum.script-coding.com/viewtopic.php?id=16008">Тема для обсуждения</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2023-03-12T03:08:18Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=157103#p157103</id>
		</entry>
</feed>
