#include #include "SSLG.au3" Global $oAudioMeterInformation = _AudioVolObject() If Not IsObj($oAudioMeterInformation) Then Exit -1 ; Will happen on non-supported systems Opt('GuiOnEventMode', 1) Global $GUI = GUICreate("GDI+ Scrolling Single Line Graph", 800, 500, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU, $WS_MINIMIZEBOX)) OnAutoItExitRegister(_Exit) GUISetOnEvent(-3, _Exit) ;_SSLG_CreateGraph($iLeft, $iTop, $iWidth, $iHeight, $iY_Min, $iY_Max, $iIncrements, $iBackGround = Default) Global $Graph1 = _SSLG_CreateGraph(10, 10, -20, 300, 0, 100, 600) GUICtrlSetOnEvent(-1, graph_) ;_SSLG_SetGrid($idSSLG, $iX_c, $iY_c, $iGridColor = Default, $iPenSize = Default) _SSLG_SetGrid($Graph1, 100, 10) _SSLG_ClearGraph($Graph1) ;Create already cleared the graph but we want a grid GUISetState() AdlibRegister(_SamplePeak, 25) AdlibRegister(_UpdateGraph, 300) GUIRegisterMsg($WM_EXITSIZEMOVE, WM_EXITSIZEMOVE) While 1 Sleep(1000) WEnd Func _SamplePeak() Local Const $S_OK = 0 Local $iPeak If $oAudioMeterInformation.GetPeakValue($iPeak) = $S_OK Then _SSLG_AddSample($Graph1, 100 * $iPeak) EndIf EndFunc Func _UpdateGraph() ;_SSLG_UpdateGraph($idSSLG, $bCompress = False, $bFill = False) _SSLG_UpdateGraph($Graph1, True, False) EndFunc Func WM_EXITSIZEMOVE($hWnd, $Msg, $wParam, $lParam) _SSLG_SetResizeGraph($Graph1) Return $GUI_RUNDEFMSG EndFunc ;==>WM_EXITSIZEMOVE Func graph_() ConsoleWrite("*Click*" & @CRLF) EndFunc Func _Exit() AdlibUnRegister(_SamplePeak) AdlibUnRegister(_UpdateGraph) OnAutoItExitUnRegister(_Exit) Exit EndFunc ;==>_Exit ;------------------------------------------------------------------------------------------------------------------------------------- ; https://www.autoitscript.com/forum/topic/142523-master-loudnessvolume-via-peak-meter-windows-7-64-bit/?tab=comments#comment-1003940 ;------------------------------------------------------------------------------------------------------------------------------------- Func _AudioVolObject() Local Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}" Local Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}" Local Const $tagIMMDeviceEnumerator = "EnumAudioEndpoints hresult(dword;dword;ptr*);" & _ "GetDefaultAudioEndpoint hresult(dword;dword;ptr*);" & _ "GetDevice hresult(wstr;ptr*);" & _ "RegisterEndpointNotificationCallback hresult(ptr);" & _ "UnregisterEndpointNotificationCallback hresult(ptr);" ; Sequences of code below are taken from the source of plugin written for AutoIt for setting master volume on Vista and above systems. ; Code was written by wraithdu in C++. ; MMDeviceEnumerator Local $oMMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $tagIMMDeviceEnumerator) If @error Then Return SetError(1, 0, 0) Local Const $eRender = 0 Local Const $eConsole = 0 ; DefaultAudioEndpoint Local $pDefaultDevice $oMMDeviceEnumerator.GetDefaultAudioEndpoint($eRender, $eConsole, $pDefaultDevice) If Not $pDefaultDevice Then Return SetError(2, 0, 0) ; Turn that pointer into object Local $oIMMDefaultDevice = ObjCreateInterface($pDefaultDevice, "{D666063F-1587-4E43-81F1-B948E807363F}", _ "Activate hresult(clsid;dword;variant*;ptr*);") Local Const $CLSCTX_INPROC_SERVER = 0x1 ; AudioMeterInformation Local $pAudioMeterInformation $oIMMDefaultDevice.Activate("{C02216F6-8C67-4B5B-9D00-D008E73E0064}", $CLSCTX_INPROC_SERVER, 0, $pAudioMeterInformation) If Not $pAudioMeterInformation Then Return SetError(3, 0, 0) Return ObjCreateInterface($pAudioMeterInformation, "{C02216F6-8C67-4B5B-9D00-D008E73E0064}", "GetPeakValue hresult(float*);") EndFunc ;------------------------------------------------------------------------------------------------------------------------------------- ; https://www.autoitscript.com/forum/topic/142523-master-loudnessvolume-via-peak-meter-windows-7-64-bit/?tab=comments#comment-1003940 ;-------------------------------------------------------------------------------------------------------------------------------------