#Include <string.au3>
#Include <GUIConstants.au3>
#include <misc.au3>
$dot = False
$bg = 0x222222
$graph = 0xFFFFFF
Opt( "GUIOnEventMode", 1 )
Dim $lpszDevice
Dim $lpszDeviceID
Dim $lpszOpenFlags
Dim $lpszRequest
Dim $lpszFlags
Dim $lpszCommand
Dim $lpszReturnString
Dim $cchReturn
Dim $mciError
$lpszDevice = "new type waveaudio"
$lpszOpenFlags = "alias mywave"
$lpszFlags = ""
$lpszCommand = StringFormat( "open %s %s %s", $lpszDevice, $lpszOpenFlags, $lpszFlags)
$lpszReturnString = _StringRepeat( " ", 100)
$cchReturn = StringLen($lpszReturnString)
$mciError = _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, 0);
If $mciError[0] <> 0 Then _mciShowError($mciError[0])
$lpszDeviceID = "mywave"
$lpszRequest = "level"
$lpszFlags = ""
$lpszCommand = StringFormat( "status %s %s %s", $lpszDeviceID, $lpszRequest, $lpszFlags);
$Form1 = GUICreate("GRAPHICAL WAVE BY ZEROCOOL", 281, 197, 193, 115)
$box = GuiCtrlCreateGraphic(0, 8, 281, 107)
GUICtrlSetBkColor(-1,$bg)
GUICtrlSetColor(-1,0)
GUICtrlSetGraphic( -1, $GUI_GR_MOVE, 0, 107/2)
GUICtrlSetGraphic( -1, $GUI_GR_LINE, 281, 107/2)
$marker = GuiCtrlCreateGraphic(0, 8, 1, 107)
GUICtrlSetBkColor(-1,0xFFFFFF)
$Button1 = GUICtrlCreateButton("Start", 0, 120, 89, 33, 0)
$Button2 = GUICtrlCreateButton("Stop", 96, 120, 89, 33, 0)
$Button3 = GUICtrlCreateButton("Clear", 192, 120, 89, 33, 0)
$Button4 = GUICtrlCreateButton("BG Color", 0, 160, 89, 33, 0)
$Button5 = GUICtrlCreateButton("Graph Color", 192, 160, 89, 33, 0)
$Button6 = GUICtrlCreateButton("Lines/Dots", 96, 160, 89, 33, 0)
GUISetState(@SW_SHOW)
GUICtrlSetOnEvent ( $Button1, "start" )
GUICtrlSetOnEvent ( $Button2, "stop" )
GUICtrlSetOnEvent ( $Button3, "clear" )
GUICtrlSetOnEvent ( $Button4, "graph_color" )
GUICtrlSetOnEvent ( $Button5, "bg_color" )
GUICtrlSetOnEvent ( $Button6, "toggle" )
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
$point = 0
$run = False
While 1
If $run = True Then
$mciError = _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, 0);
If $mciError[0] <> 0 Then _mciShowError($mciError[0])
If $dot = True Then
GUICtrlSetGraphic( $box, $GUI_GR_COLOR, $graph)
GUICtrlSetGraphic( $box, $GUI_GR_DOT, $point, (107/2)+$mciError[2]/2 )
GUICtrlSetGraphic( $box, $GUI_GR_DOT, $point, (107/2)-$mciError[2]/2 )
Else
GUICtrlSetGraphic( $box, $GUI_GR_MOVE, $point, 107/2)
GUICtrlSetGraphic( $box, $GUI_GR_COLOR, $graph)
GUICtrlSetGraphic( $box, $GUI_GR_LINE, $point, (107/2)+$mciError[2]/2 )
GUICtrlSetGraphic( $box, $GUI_GR_LINE, $point, (107/2)-$mciError[2]/2 )
EndIf
$point = $point + 1
If $point > 280 Then
GUICtrlDelete( $box )
GUICtrlDelete( $marker )
$box = GuiCtrlCreateGraphic(0, 8, 281, 107)
GUICtrlSetGraphic( -1, $GUI_GR_MOVE, 0, 107/2)
GUICtrlSetGraphic( -1, $GUI_GR_COLOR, $graph)
GUICtrlSetGraphic( -1, $GUI_GR_LINE, 281, 107/2)
GUICtrlSetBkColor(-1,$bg)
GUICtrlSetColor(-1,0)
GUICtrlSetGraphic( -1, $GUI_GR_MOVE, 0, 107/2)
GUICtrlSetGraphic( -1, $GUI_GR_COLOR, $graph)
GUICtrlSetGraphic( -1, $GUI_GR_LINE, 281, 107/2)
$marker = GuiCtrlCreateGraphic(0, 8, 3, 107)
GUICtrlSetBkColor(-1,0xFFFFFF)
$point = 0
Sleep(10)
EndIf
GUICtrlSetPos ( $marker, $point, 8 )
EndIf
Sleep(10)
WEnd
Func bg_color()
Global $bg = _ChooseColor(2, $bg, 2)
GUICtrlSetBkColor($box,$bg)
EndFunc
Func graph_color()
Global $graph = _ChooseColor(2, $graph, 2)
GUICtrlSetBkColor($marker,$graph)
EndFunc
Func toggle()
If $dot = False Then
$dot = True
Else
$dot = False
EndIf
EndFunc
Func start()
$run = True
EndFunc
Func stop()
$run = False
EndFunc
Func clear()
GUICtrlDelete( $box )
GUICtrlDelete( $marker )
$box = GuiCtrlCreateGraphic(0, 8, 281, 107)
GUICtrlSetBkColor(-1,$bg)
GUICtrlSetColor(-1,0)
GUICtrlSetGraphic( -1, $GUI_GR_MOVE, 0, 107/2)
GUICtrlSetGraphic( -1, $GUI_GR_COLOR, $graph)
GUICtrlSetGraphic( -1, $GUI_GR_LINE, 281, 107/2)
$marker = GuiCtrlCreateGraphic(0, 8, 3, 107)
GUICtrlSetBkColor(-1,$graph)
$point = 0
EndFunc
Func SpecialEvents()
Exit
EndFunc
Func _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, $hwndCallback)
Return DllCall("winmm.dll", "long", "mciSendStringA", "str", $lpszCommand, "str", $lpszReturnString, "long", $cchReturn, "long", 0)
EndFunc ;==>_mciSendString
Func _mciShowError($mciError)
Dim $errStr; Error message
$errStr = _StringRepeat( " ", 100) ; Reserve some space for the error message
$Result = DllCall("winmm.dll", "long", "mciGetErrorStringA", "long", $mciError, "string", $errStr, "long", StringLen($errStr))
MsgBox(0, "MCI test", "MCI Error Number " & $mciError & ":" & $Result[2])
EndFunc ;==>_mciShowError