Opt('GUIOnEventMode', 1)
Global $point = 0
$Form1 = GUICreate('录音机 - winmm.dll', 281, 160, -1, -1)
GUISetOnEvent(-3, 'SpecialEvents')
$box = GUICtrlCreateGraphic(0, 8, 281, 107)
GUICtrlSetBkColor($box, 0x222222)
GUICtrlSetColor(-1, 0)
GUICtrlSetGraphic(-1, 6, 0, 107 / 2)
GUICtrlSetGraphic(-1, 2, 281, 107 / 2)
$marker = GUICtrlCreateGraphic(0, 8, 1, 107)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Start = GUICtrlCreateButton('Start', 0, 120, 89, 33, 0)
GUICtrlSetOnEvent(-1, 'SpecialEvents')
$Stop = GUICtrlCreateButton('Stop', 96, 120, 89, 33, 0)
GUICtrlSetOnEvent(-1, 'SpecialEvents')
$Save = GUICtrlCreateButton('Save', 192, 120, 89, 33, 0)
GUICtrlSetOnEvent(-1, 'SpecialEvents')
GUISetState(@SW_SHOW)
While 1
Sleep(1000)
WEnd
Func SpecialEvents()
Switch @GUI_CtrlId
Case -3
Exit
Case $Start
__SoundMciSendString('Open New type WaveAudio alias recorder')
__SoundMciSendString('Open New type WaveAudio alias recorderTemp')
__SoundMciSendString('set recorder bitspersample 8');使用8位
__SoundMciSendString('set recorder samplespersec 11025');11025Hz
__SoundMciSendString('set recorder channels 2');立体声(双声道)
__SoundMciSendString('record recorder');开始录音
AdlibRegister('recorder', 10)
Case $Stop
AdlibUnRegister('recorder')
__SoundMciSendString('stop recorder')
Case $Save
AdlibUnRegister('recorder')
__SoundMciSendString('stop recorder')
$Save = FileSaveDialog('', @DesktopDir, '录音文件 (*.wav)', 18, 'test.wav', $Form1)
If Not @error Then __SoundMciSendString('save recorder "' & $Save & '"')
__SoundMciSendString('close recorderTemp')
__SoundMciSendString('close recorder')
EndSwitch
EndFunc ;==>SpecialEvents
Func recorder()
$level = __SoundMciSendString('status recorderTemp level')
ToolTip($level, 0, 0)
GUICtrlSetGraphic($box, 6, $point, 107 / 2)
GUICtrlSetGraphic($box, 8, 0xFFFFFF)
GUICtrlSetGraphic($box, 2, $point, (107 / 2) + $level / 2)
GUICtrlSetGraphic($box, 2, $point, (107 / 2) - $level / 2)
$point = $point + 1
If $point > 280 Then
GUICtrlDelete($box)
GUICtrlDelete($marker)
$box = GUICtrlCreateGraphic(0, 8, 281, 107)
GUICtrlSetBkColor($box, 0x222222)
GUICtrlSetGraphic(-1, 6, 0, 107 / 2)
GUICtrlSetGraphic(-1, 8, 0xFFFFFF)
GUICtrlSetGraphic(-1, 2, 281, 107 / 2)
GUICtrlSetColor(-1, 0)
GUICtrlSetGraphic(-1, 6, 0, 107 / 2)
GUICtrlSetGraphic(-1, 8, 0xFFFFFF)
GUICtrlSetGraphic(-1, 2, 281, 107 / 2)
$marker = GUICtrlCreateGraphic(0, 8, 3, 107)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$point = 0
EndIf
GUICtrlSetPos($marker, $point, 8)
EndFunc ;==>recorder
Func __SoundMciSendString($string, $iLen = 65534)
Local $iRet = DllCall('winmm.dll', 'int', 'mciSendString', 'str', $string, 'str', '', 'int', $iLen, 'hwnd', 0)
Return $iRet[2]
EndFunc ;==>__SoundMciSendString