#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>
Local $musicf, $_audio, $btn1, $btn2, $btn3, $btn4, $sound
#Region ### START GUI section ###
$musicf = "e:\smrf.mp3"
$_audio = GUICreate("左右声道测试V1.0 By:Tom_Zhou", 400, 100)
$btn1 = GUICtrlCreateButton("双声道", 20, 30, 60, 25, $BS_DEFPUSHBUTTON)
$btn2 = GUICtrlCreateButton("左声道", 90, 30, 60, 25)
$btn3 = GUICtrlCreateButton("右声道", 160, 30, 60, 25)
$btn4 = GUICtrlCreateButton("退 出", 230, 30, 60, 25)
GUISetState()
#EndRegion ### end GUI section ###
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $btn1
_LR()
Case $btn2
DllCall('winmm.dll', 'none', 'waveOutSetVolume', 'hwnd', 0, 'dword', 0xFFFF0000)
Case $btn3
DllCall('winmm.dll', 'none', 'waveOutSetVolume', 'hwnd', 0, 'dword', 0x0000FFFF)
Case $btn4
_SoundClose($sound)
ExitLoop
EndSwitch
WEnd
Func _LR()
$sound = _SoundOpen($musicf, "Startup")
If @error = 2 Then
MsgBox(0, "Error", "The file does not exist")
Exit
ElseIf @error = 3 Then
MsgBox(0, "Error", "The alias was invalid")
Exit
ElseIf @extended <> 0 Then
$extended = @extended
$stText = DllStructCreate("char[128]")
$errorstring = DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $extended, "ptr", DllStructGetPtr($stText), "int", 128)
MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & DllStructGetData($stText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
EndIf
_SoundPlay($sound)
;DllCall('winmm.dll', 'none', 'waveOutSetVolume', 'hwnd', 0, 'dword', 0x0000FFFF)
EndFunc