Belini got a reaction from
Danyfirex in Control *Application* Sound Volume?
February 22, 2020
I use MixerGetSet.au3 to control the sound of various pc devices.
$asComponentTypes[0] = "dUndefined"
$asComponentTypes[1] = "dDigital"
$asComponentTypes[2] = "dLine"
$asComponentTypes[3] = "dMonitor"
$asComponentTypes[4] = "dSpeakers"
$asComponentTypes[5] = "dHeadphones"
$asComponentTypes[6] = "dTelephone"
$asComponentTypes[7] = "dWave"
$asComponentTypes[8] = "dVoice"
$asComponentTypes[9] = "sUndefined"
$asComponentTypes[10] = "sDigital"
$asComponentTypes[11] = "sLine"
$asComponentTypes[12] = "sMicrophone"
$asComponentTypes[13] = "sSynthesizer"
$asComponentTypes[14] = "sCompactDisc"
$asComponentTypes[15] = "sTelephone"
$asComponentTypes[16] = "sPCSpeaker"
$asComponentTypes[17] = "sWave"
$asComponentTypes[18] = "sAuxiliary"
$asComponentTypes[19] = "sAnalog"
#include <GUIConstants.au3>
Const $MCA_WMID = 1
Const $MCA_WPID = 2
Const $MCA_VDRIVERVERSION = 3
Const $MCA_SZPNAME = 4
Const $MCA_FDWSUPPORT = 5
Const $MCA_CDESTINATIONS = 6
Const $MCA_STRUCT_DEF = "ushort;ushort;uint;char[32];dword;dword"
Const $ML_CBSTRUCT = 1
Const $ML_DWDESTINATION = 2
Const $ML_DWSOURCE = 3
Const $ML_DWLINEID = 4
Const $ML_FDWLINE = 5
Const $ML_DWUSER = 6
Const $ML_DWCOMPONENTTYPE = 7
Const $ML_CCHANNELS = 8
Const $ML_CCONNECTIONS = 9
Const $ML_CCONTROLS = 10
Const $ML_SZSHORTNAME = 11
Const $ML_SZNAME = 12
Const $ML_DWTYPE = 13
Const $ML_DWDEVICEID = 14
Const $ML_WMID = 15
Const $ML_WPID = 16
Const $ML_VDRIVERVERSION = 17
Const $ML_SZPNAME = 18
Const $ML_STRUCT_DEF = "dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;char[16];char[64];dword;dword;ushort;ushort;uint;char[32]"
Const $MCO_CBSTRUCT = 1
Const $MCO_DWCONTROLID = 2
Const $MCO_DWCONTROLTYPE = 3
Const $MCO_FDWCONTROL = 4
Const $MCO_CMULTIPLEITEMS = 5
Const $MCO_SZSHORTNAME = 6
Const $MCO_SZNAME = 7
Const $MCO_LMINIMUM = 8
Const $MCO_LMAXIMUM = 9
Const $MCO_DWMINIMUM = 8
Const $MCO_DWMAXIMUM = 9
Const $MCO_DWRESERVED_1 = 10
Const $MCO_CSTEPS = 11
Const $MCO_CBCUSTOMDATA = 11
Const $MCO_DWRESERVED_2 = 12
Const $MCO_STRUCT_DEF = "dword;dword;dword;dword;dword;char[16];char[64];dword;dword;dword[4];dword;dword[5]"
Const $MLC_CBSTRUCT = 1
Const $MLC_DWLINEID = 2
Const $MLC_DWCONTROLID = 3
Const $MLC_DWCONTROLTYPE = 3
Const $MLC_CCONTROLS = 4
Const $MLC_CBMXCTRL = 5
Const $MLC_PAMXCTRL = 6
Const $MLC_STRUCT_DEF = "dword;dword;dword;dword;dword;ptr"
Const $MCD_CBSTRUCT = 1
Const $MCD_DWCONTROLID = 2
Const $MCD_CCHANNELS = 3
Const $MCD_HWNDOWNER = 4
Const $MCD_CMULTIPLEITEMS = 4
Const $MCD_CBDETAILS = 5
Const $MCD_PADETAILS = 6
Const $MCD_STRUCT_DEF = "dword;dword;dword;dword;dword;ptr"
Const $MCDU_DWVALUE = 1
Const $MCDU_STRUCT_DEF = "dword"
Const $MIXERLINE_COMPONENTTYPE_DST_FIRST = 0x00000000
Const $MIXERLINE_COMPONENTTYPE_DST_UNDEFINED = $MIXERLINE_COMPONENTTYPE_DST_FIRST + 0
Const $MIXERLINE_COMPONENTTYPE_DST_DIGITAL = $MIXERLINE_COMPONENTTYPE_DST_FIRST + 1
Const $MIXERLINE_COMPONENTTYPE_DST_LINE = $MIXERLINE_COMPONENTTYPE_DST_FIRST + 2
Const $MIXERLINE_COMPONENTTYPE_DST_MONITOR = $MIXERLINE_COMPONENTTYPE_DST_FIRST + 3
Const $MIXERLINE_COMPONENTTYPE_DST_SPEAKERS = $MIXERLINE_COMPONENTTYPE_DST_FIRST + 4
Const $MIXERLINE_COMPONENTTYPE_DST_HEADPHONES = $MIXERLINE_COMPONENTTYPE_DST_FIRST + 5
Const $MIXERLINE_COMPONENTTYPE_DST_TELEPHONE = $MIXERLINE_COMPONENTTYPE_DST_FIRST + 6
Const $MIXERLINE_COMPONENTTYPE_DST_WAVEIN = $MIXERLINE_COMPONENTTYPE_DST_FIRST + 7
Const $MIXERLINE_COMPONENTTYPE_DST_VOICEIN = $MIXERLINE_COMPONENTTYPE_DST_FIRST + 8
Const $MIXERLINE_COMPONENTTYPE_DST_LAST = $MIXERLINE_COMPONENTTYPE_DST_FIRST + 8
Const $MIXERLINE_COMPONENTTYPE_SRC_FIRST = 0x00001000
Const $MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED = $MIXERLINE_COMPONENTTYPE_SRC_FIRST + 0
Const $MIXERLINE_COMPONENTTYPE_SRC_DIGITAL = $MIXERLINE_COMPONENTTYPE_SRC_FIRST + 1
Const $MIXERLINE_COMPONENTTYPE_SRC_LINE = $MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2
Const $MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE = $MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3
Const $MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER = $MIXERLINE_COMPONENTTYPE_SRC_FIRST + 4
Const $MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC = $MIXERLINE_COMPONENTTYPE_SRC_FIRST + 5
Const $MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE = $MIXERLINE_COMPONENTTYPE_SRC_FIRST + 6
Const $MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER = $MIXERLINE_COMPONENTTYPE_SRC_FIRST + 7
Const $MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT = $MIXERLINE_COMPONENTTYPE_SRC_FIRST + 8
Const $MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY = $MIXERLINE_COMPONENTTYPE_SRC_FIRST + 9
Const $MIXERLINE_COMPONENTTYPE_SRC_ANALOG = $MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10
Const $MIXERLINE_COMPONENTTYPE_SRC_LAST = $MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10
Global $aiComponentTypes[20]
Global $asComponentTypes[20]
$aiComponentTypes[0] = $MIXERLINE_COMPONENTTYPE_DST_UNDEFINED
$aiComponentTypes[1] = $MIXERLINE_COMPONENTTYPE_DST_DIGITAL
$aiComponentTypes[2] = $MIXERLINE_COMPONENTTYPE_DST_LINE
$aiComponentTypes[3] = $MIXERLINE_COMPONENTTYPE_DST_MONITOR
$aiComponentTypes[4] = $MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
$aiComponentTypes[5] = $MIXERLINE_COMPONENTTYPE_DST_HEADPHONES
$aiComponentTypes[6] = $MIXERLINE_COMPONENTTYPE_DST_TELEPHONE
$aiComponentTypes[7] = $MIXERLINE_COMPONENTTYPE_DST_WAVEIN
$aiComponentTypes[8] = $MIXERLINE_COMPONENTTYPE_DST_VOICEIN
$aiComponentTypes[9] = $MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED
$aiComponentTypes[10] = $MIXERLINE_COMPONENTTYPE_SRC_DIGITAL
$aiComponentTypes[11] = $MIXERLINE_COMPONENTTYPE_SRC_LINE
$aiComponentTypes[12] = $MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE
$aiComponentTypes[13] = $MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER
$aiComponentTypes[14] = $MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
$aiComponentTypes[15] = $MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE
$aiComponentTypes[16] = $MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER
$aiComponentTypes[17] = $MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT
$aiComponentTypes[18] = $MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY
$aiComponentTypes[19] = $MIXERLINE_COMPONENTTYPE_SRC_ANALOG
$asComponentTypes[0] = "dUndefined"
$asComponentTypes[1] = "dDigital"
$asComponentTypes[2] = "dLine"
$asComponentTypes[3] = "dMonitor"
$asComponentTypes[4] = "dSpeakers"
$asComponentTypes[5] = "dHeadphones"
$asComponentTypes[6] = "dTelephone"
$asComponentTypes[7] = "dWave"
$asComponentTypes[8] = "dVoice"
$asComponentTypes[9] = "sUndefined"
$asComponentTypes[10] = "sDigital"
$asComponentTypes[11] = "sLine"
$asComponentTypes[12] = "sMicrophone"
$asComponentTypes[13] = "sSynthesizer"
$asComponentTypes[14] = "sCompactDisc"
$asComponentTypes[15] = "sTelephone"
$asComponentTypes[16] = "sPCSpeaker"
$asComponentTypes[17] = "sWave"
$asComponentTypes[18] = "sAuxiliary"
$asComponentTypes[19] = "sAnalog"
Const $MIXERCONTROL_CT_CLASS_CUSTOM = 0x00000000
Const $MIXERCONTROL_CT_CLASS_METER = 0x10000000
Const $MIXERCONTROL_CT_CLASS_SWITCH = 0x20000000
Const $MIXERCONTROL_CT_CLASS_NUMBER = 0x30000000
Const $MIXERCONTROL_CT_CLASS_SLIDER = 0x40000000
Const $MIXERCONTROL_CT_CLASS_FADER = 0x50000000
Const $MIXERCONTROL_CT_CLASS_TIME = 0x60000000
Const $MIXERCONTROL_CT_CLASS_LIST = 0x70000000
Const $MIXERCONTROL_CT_SC_SWITCH_BOOLEAN = 0x00000000
Const $MIXERCONTROL_CT_SC_SWITCH_BUTTON = 0x01000000
Const $MIXERCONTROL_CT_SC_METER_POLLED = 0x00000000
Const $MIXERCONTROL_CT_SC_TIME_MICROSECS = 0x00000000
Const $MIXERCONTROL_CT_SC_TIME_MILLISECS = 0x01000000
Const $MIXERCONTROL_CT_SC_LIST_SINGLE = 0x00000000
Const $MIXERCONTROL_CT_SC_LIST_MULTIPLE = 0x01000000
Const $MIXERCONTROL_CT_UNITS_CUSTOM = 0x00000000
Const $MIXERCONTROL_CT_UNITS_BOOLEAN = 0x00010000
Const $MIXERCONTROL_CT_UNITS_SIGNED = 0x00020000
Const $MIXERCONTROL_CT_UNITS_UNSIGNED = 0x00030000
Const $MIXERCONTROL_CT_UNITS_DECIBELS = 0x00040000
Const $MIXERCONTROL_CT_UNITS_PERCENT = 0x00050000
Const $MIXERCONTROL_CONTROLTYPE_CUSTOM = BitOR($MIXERCONTROL_CT_CLASS_CUSTOM, $MIXERCONTROL_CT_UNITS_CUSTOM)
Const $MIXERCONTROL_CONTROLTYPE_BOOLEANMETER = BitOR($MIXERCONTROL_CT_CLASS_METER, $MIXERCONTROL_CT_SC_METER_POLLED, $MIXERCONTROL_CT_UNITS_BOOLEAN)
Const $MIXERCONTROL_CONTROLTYPE_SIGNEDMETER = BitOR($MIXERCONTROL_CT_CLASS_METER, $MIXERCONTROL_CT_SC_METER_POLLED, $MIXERCONTROL_CT_UNITS_SIGNED)
Const $MIXERCONTROL_CONTROLTYPE_PEAKMETER = $MIXERCONTROL_CONTROLTYPE_SIGNEDMETER + 1
Const $MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER = BitOR($MIXERCONTROL_CT_CLASS_METER, $MIXERCONTROL_CT_SC_METER_POLLED, $MIXERCONTROL_CT_UNITS_UNSIGNED)
Const $MIXERCONTROL_CONTROLTYPE_BOOLEAN = BitOR($MIXERCONTROL_CT_CLASS_SWITCH, $MIXERCONTROL_CT_SC_SWITCH_BOOLEAN, $MIXERCONTROL_CT_UNITS_BOOLEAN)
Const $MIXERCONTROL_CONTROLTYPE_ONOFF = $MIXERCONTROL_CONTROLTYPE_BOOLEAN + 1
Const $MIXERCONTROL_CONTROLTYPE_MUTE = $MIXERCONTROL_CONTROLTYPE_BOOLEAN + 2
Const $MIXERCONTROL_CONTROLTYPE_MONO = $MIXERCONTROL_CONTROLTYPE_BOOLEAN + 3
Const $MIXERCONTROL_CONTROLTYPE_LOUDNESS = $MIXERCONTROL_CONTROLTYPE_BOOLEAN + 4
Const $MIXERCONTROL_CONTROLTYPE_STEREOENH = $MIXERCONTROL_CONTROLTYPE_BOOLEAN + 5
Const $MIXERCONTROL_CONTROLTYPE_BUTTON = BitOR($MIXERCONTROL_CT_CLASS_SWITCH, $MIXERCONTROL_CT_SC_SWITCH_BUTTON, $MIXERCONTROL_CT_UNITS_BOOLEAN)
Const $MIXERCONTROL_CONTROLTYPE_DECIBELS = BitOR($MIXERCONTROL_CT_CLASS_NUMBER, $MIXERCONTROL_CT_UNITS_DECIBELS)
Const $MIXERCONTROL_CONTROLTYPE_SIGNED = BitOR($MIXERCONTROL_CT_CLASS_NUMBER, $MIXERCONTROL_CT_UNITS_SIGNED)
Const $MIXERCONTROL_CONTROLTYPE_UNSIGNED = BitOR($MIXERCONTROL_CT_CLASS_NUMBER, $MIXERCONTROL_CT_UNITS_UNSIGNED)
Const $MIXERCONTROL_CONTROLTYPE_PERCENT = BitOR($MIXERCONTROL_CT_CLASS_NUMBER, $MIXERCONTROL_CT_UNITS_PERCENT)
Const $MIXERCONTROL_CONTROLTYPE_SLIDER = BitOR($MIXERCONTROL_CT_CLASS_SLIDER, $MIXERCONTROL_CT_UNITS_SIGNED)
Const $MIXERCONTROL_CONTROLTYPE_PAN = $MIXERCONTROL_CONTROLTYPE_SLIDER + 1
Const $MIXERCONTROL_CONTROLTYPE_QSOUNDPAN = $MIXERCONTROL_CONTROLTYPE_SLIDER + 2
Const $MIXERCONTROL_CONTROLTYPE_FADER = BitOR($MIXERCONTROL_CT_CLASS_FADER, $MIXERCONTROL_CT_UNITS_UNSIGNED)
Const $MIXERCONTROL_CONTROLTYPE_VOLUME = $MIXERCONTROL_CONTROLTYPE_FADER + 1
Const $MIXERCONTROL_CONTROLTYPE_BASS = $MIXERCONTROL_CONTROLTYPE_FADER + 2
Const $MIXERCONTROL_CONTROLTYPE_TREBLE = $MIXERCONTROL_CONTROLTYPE_FADER + 3
Const $MIXERCONTROL_CONTROLTYPE_EQUALIZER = $MIXERCONTROL_CONTROLTYPE_FADER + 4
Const $MIXERCONTROL_CONTROLTYPE_SINGLESELECT = BitOR($MIXERCONTROL_CT_CLASS_LIST, $MIXERCONTROL_CT_SC_LIST_SINGLE, $MIXERCONTROL_CT_UNITS_BOOLEAN)
Const $MIXERCONTROL_CONTROLTYPE_MUX = $MIXERCONTROL_CONTROLTYPE_SINGLESELECT + 1
Const $MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT = BitOR($MIXERCONTROL_CT_CLASS_LIST, $MIXERCONTROL_CT_SC_LIST_MULTIPLE, $MIXERCONTROL_CT_UNITS_BOOLEAN)
Const $MIXERCONTROL_CONTROLTYPE_MIXER = $MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT + 1
Const $MIXERCONTROL_CONTROLTYPE_MICROTIME = BitOR($MIXERCONTROL_CT_CLASS_TIME, $MIXERCONTROL_CT_SC_TIME_MICROSECS, $MIXERCONTROL_CT_UNITS_UNSIGNED)
Const $MIXERCONTROL_CONTROLTYPE_MILLITIME = BitOR($MIXERCONTROL_CT_CLASS_TIME, $MIXERCONTROL_CT_SC_TIME_MILLISECS, $MIXERCONTROL_CT_UNITS_UNSIGNED)
Global $aiControlTypes[30]
Global $asControlTypes[30]
$aiControlTypes[0] = $MIXERCONTROL_CONTROLTYPE_CUSTOM
$aiControlTypes[1] = $MIXERCONTROL_CONTROLTYPE_BOOLEANMETER
$aiControlTypes[2] = $MIXERCONTROL_CONTROLTYPE_SIGNEDMETER
$aiControlTypes[3] = $MIXERCONTROL_CONTROLTYPE_PEAKMETER
$aiControlTypes[4] = $MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER
$aiControlTypes[5] = $MIXERCONTROL_CONTROLTYPE_BOOLEAN
$aiControlTypes[6] = $MIXERCONTROL_CONTROLTYPE_ONOFF
$aiControlTypes[7] = $MIXERCONTROL_CONTROLTYPE_MUTE
$aiControlTypes[8] = $MIXERCONTROL_CONTROLTYPE_MONO
$aiControlTypes[9] = $MIXERCONTROL_CONTROLTYPE_LOUDNESS
$aiControlTypes[10] = $MIXERCONTROL_CONTROLTYPE_STEREOENH
$aiControlTypes[11] = $MIXERCONTROL_CONTROLTYPE_BUTTON
$aiControlTypes[12] = $MIXERCONTROL_CONTROLTYPE_DECIBELS
$aiControlTypes[13] = $MIXERCONTROL_CONTROLTYPE_SIGNED
$aiControlTypes[14] = $MIXERCONTROL_CONTROLTYPE_UNSIGNED
$aiControlTypes[15] = $MIXERCONTROL_CONTROLTYPE_PERCENT
$aiControlTypes[16] = $MIXERCONTROL_CONTROLTYPE_SLIDER
$aiControlTypes[17] = $MIXERCONTROL_CONTROLTYPE_PAN
$aiControlTypes[18] = $MIXERCONTROL_CONTROLTYPE_QSOUNDPAN
$aiControlTypes[19] = $MIXERCONTROL_CONTROLTYPE_FADER
$aiControlTypes[20] = $MIXERCONTROL_CONTROLTYPE_VOLUME
$aiControlTypes[21] = $MIXERCONTROL_CONTROLTYPE_BASS
$aiControlTypes[22] = $MIXERCONTROL_CONTROLTYPE_TREBLE
$aiControlTypes[23] = $MIXERCONTROL_CONTROLTYPE_EQUALIZER
$aiControlTypes[24] = $MIXERCONTROL_CONTROLTYPE_SINGLESELECT
$aiControlTypes[25] = $MIXERCONTROL_CONTROLTYPE_MUX
$aiControlTypes[26] = $MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT
$aiControlTypes[27] = $MIXERCONTROL_CONTROLTYPE_MIXER
$aiControlTypes[28] = $MIXERCONTROL_CONTROLTYPE_MICROTIME
$aiControlTypes[29] = $MIXERCONTROL_CONTROLTYPE_MILLITIME
$asControlTypes[0] = "Custom"
$asControlTypes[1] = "BooleanMeter"
$asControlTypes[2] = "SignedMeter"
$asControlTypes[3] = "PeakMeter"
$asControlTypes[4] = "UnsignedMeter"
$asControlTypes[5] = "Boolean"
$asControlTypes[6] = "OnOff"
$asControlTypes[7] = "Mute"
$asControlTypes[8] = "Mono"
$asControlTypes[9] = "Loudness"
$asControlTypes[10] = "StereoEnh"
$asControlTypes[11] = "Button"
$asControlTypes[12] = "Decibels"
$asControlTypes[13] = "Signed"
$asControlTypes[14] = "Unsigned"
$asControlTypes[15] = "Percent"
$asControlTypes[16] = "Slider"
$asControlTypes[17] = "Pan"
$asControlTypes[18] = "QSoundPan"
$asControlTypes[19] = "Fader"
$asControlTypes[20] = "Volume"
$asControlTypes[21] = "Bass"
$asControlTypes[22] = "Treble"
$asControlTypes[23] = "Equalizer"
$asControlTypes[24] = "SingleSelect"
$asControlTypes[25] = "Mux"
$asControlTypes[26] = "MultipleSelect"
$asControlTypes[27] = "Mixer"
$asControlTypes[28] = "Microtime"
$asControlTypes[29] = "Millitime"
Const $MIXER_GETLINEINFOF_DESTINATION = 0x00000000
Const $MIXER_GETLINEINFOF_SOURCE = 0x00000001
Const $MIXER_GETLINEINFOF_LINEID = 0x00000002
Const $MIXER_GETLINEINFOF_COMPONENTTYPE = 0x00000003
Const $MIXER_GETLINEINFOF_TARGETTYPE = 0x00000004
Const $MIXER_GETLINECONTROLSF_ALL = 0x00000000
Const $MIXER_GETLINECONTROLSF_ONEBYID = 0x00000001
Const $MIXER_GETLINECONTROLSF_ONEBYTYPE = 0x00000002
Const $MIXER_GETCONTROLDETAILSF_VALUE = 0x00000000
Const $MIXER_GETCONTROLDETAILSF_LISTTEXT = 0x00000001
Const $MIXER_SETCONTROLDETAILSF_VALUE = 0x00000000
Const $MIXER_SETCONTROLDETAILSF_CUSTOM = 0x00000001
; ================================================================================= EXEMPLO
_MixerSet("dSpeakers", "volume", 0); <======== Baixa os alto falantes
Sleep(1000)
_MixerSet("dSpeakers", "volume", 100); <======== Aumenta os alto falantes
Sleep(1000)
_MixerSet("sWave", "volume", 0); <======== Baixa o som wave
Sleep(1000)
_MixerSet("sWave", "volume", 100); <======== Aumenta o som wave
; ================================================================================= EXEMPLO
;CÓDIGOS DE ERRO RETORNADOS
; 1 - ID do Mixer é inválido
; 2 - tipo de componente inválido
; 3 - instancia de componente invalida
; 4 - tipo de Controle inválido
; 5 - Não é possível abrir o Mixer especificado
; 6 - Mixer não suporta o componente especificado
; 7 - Mixer não tem o tipo de componente especificado
; 8 - componente não suporta o tipo de controle especificado
; 9 - Não é possível obter a configuração atual
; 10 - Não é possível alterar a configuração
;----------------------------------------------------------
;
; Nome: _MixerGet
; Descrição: Retorna o valor do controle solicitado
; Sintese _MixerGet($sComponentType, $sControlType)
; Parametros:
; $sComponentType - Nome do componente
;
; - dUndefined
; - dDigital
; - dLine
; - dMonitor
; - dSpeakers
; - dHeadphones
; - dTelephone
; - dWave
; - dVoice
; - sUndefined
; - sDigital
; - sLine
; - sMicrophone
; - sSynthesizer
; - sCompactDisc
; - sTelephone
; - sPCSpeaker
; - sWave
; - sAuxiliary
; - sAnalog
;
; $sControlType - Tipo de Controle
;
; - Custom
; - BooleanMeter
; - SignedMeter
; - PeakMeter
; - UnsignedMeter
; - Boolean
; - OnOff
; - Mute
; - Mono
; - Loudness
; - StereoEnh
; - Button
; - Decibels
; - Signed
; - Unsigned
; - Percent
; - Slider
; - Pan
; - QSoundPan
; - Fader
; - Volume
; - Bass
; - Treble
; - Equalizer
; - SingleSelect
; - Mux
; - MultipleSelect
; - Mixer
; - Microtime
; - Millitime
;
; Valor Retornado: Sucesso - retorna @error = 0 e o valor do controle acessado
; caixa de seleção retorna 0 or 1.
;
; Falha - Retorna 0 e código do @error :
;
; 1 - ID do Mixer é inválido
; 2 - tipo de componente inválido
; 3 - instancia de componente invalida
; 4 - tipo de Controle inválido
; 5 - Não é possível abrir o Mixer especificado
; 6 - Mixer não suporta o componente especificado
; 7 - Mixer não tem o tipo de componente especificado
; 8 - componente não suporta o tipo de controle especificado
; 9 - Não é possível obter a configuração atual
; 10 - Não é possível alterar a configuração
;
;
;
;-------------------------------------------------------------
Func _MixerGet($sComponentType, $sControlType)
$iMixerID = 0
$iComponentInstance = 1
Local $iRet = MixerSetGet($iMixerID, $sComponentType, $iComponentInstance, $sControlType, False, 0)
SetError(@error)
Return $iRet
EndFunc ;==>_MixerGet
;----------------------------
;
; Nome: _MixerSet
; Descrição: Grava o valor no controle especificado
;
; Síntese: _MixerSet($sComponentType, $sControlType, $iNewParamValue)
;
; Parametros: $sComponentType = Nome do componente (os mesmos da lista de _MixerGet)
;
; $sControlType - Tipo de Controle (os mesmos da lista de _MixerGet)
;
;
;
; $iNewParamValue = Novo valor
; Para controles (caixa de seleção) zero é igual Off e 1 é igual On.
; Para outros controles este é um percentual de 0 a 100
;
; Valores Retornados: Successo Retorna @error = 0 e o valor fixado no controle
;
; Falha - Retorna 0 e código do @error (os mesmos da lista de _MixerGet)
;
;-----------------------------------------------------------------------------------------------
Func _MixerSet($sComponentType, $sControlType, $iNewParamValue)
$iMixerID = 0
$iComponentInstance = 1
Local $iRet = MixerSetGet($iMixerID, $sComponentType, $iComponentInstance, $sControlType, True, $iNewParamValue)
SetError(@error)
Return $iRet
EndFunc ;==>_MixerSet
; Funções Internas
Func MixerOpen(ByRef $hMixer, $iMixerID, $hCallback, $iInstance, $iFlags)
Local $hStruct = DllStructCreate("ptr")
Local $iRet = DllCall("winmm.dll", "uint", "mixerOpen", "ptr", DllStructGetPtr($hStruct), "uint", $iMixerID, "dword", $hCallback, "dword", $iInstance, "dword", $iFlags)
If @error Or $iRet[0] Then
Return False
Else
$hMixer = DllStructGetData($hStruct, 1)
Return True
EndIf
EndFunc ;==>MixerOpen
Func MixerClose($hMixer)
Local $iRet = DllCall("winmm.dll", "uint", "mixerClose", "uint", $hMixer)
If @error Or $iRet[0] Then
Return False
Else
Return True
EndIf
EndFunc ;==>MixerClose
Func MixerGetDevCaps($hMixer, ByRef $hMxCaps)
Local $iRet = DllCall("winmm.dll", "uint", "mixerGetDevCaps", "uint", $hMixer, "ptr", DllStructGetPtr($hMxCaps), "uint", DllStructGetSize($hMxCaps))
If @error Or $iRet[0] Then
Return False
Else
Return True
EndIf
EndFunc ;==>MixerGetDevCaps
Func MixerGetLineInfo($hMixer, ByRef $hMxLine, $iFlags)
DllStructSetData($hMxLine, $ML_CBSTRUCT, DllStructGetSize($hMxLine))
Local $iRet = DllCall("winmm.dll", "uint", "mixerGetLineInfo", "uint", $hMixer, "ptr", DllStructGetPtr($hMxLine), "dword", $iFlags)
If @error Or $iRet[0] Then
Return False
Else
Return True
EndIf
EndFunc ;==>MixerGetLineInfo
Func MixerGetLineControls($hMixer, ByRef $hMxLineCtrls, $iFlags)
DllStructSetData($hMxLineCtrls, $MLC_CBSTRUCT, DllStructGetSize($hMxLineCtrls))
Local $iRet = DllCall("winmm.dll", "uint", "mixerGetLineControls", "uint", $hMixer, "ptr", DllStructGetPtr($hMxLineCtrls), "dword", $iFlags)
If @error Or $iRet[0] Then
Return False
Else
Return True
EndIf
EndFunc ;==>MixerGetLineControls
Func MixerGetControlDetails($hMixer, ByRef $hMxCtrlDetails, $iFlags)
DllStructSetData($hMxCtrlDetails, $MCD_CBSTRUCT, DllStructGetSize($hMxCtrlDetails))
Local $iRet = DllCall("winmm.dll", "uint", "mixerGetControlDetails", "uint", $hMixer, "ptr", DllStructGetPtr($hMxCtrlDetails), "dword", $iFlags)
If @error Or $iRet[0] Then
Return False
Else
Return True
EndIf
EndFunc ;==>MixerGetControlDetails
Func MixerSetControlDetails($hMixer, ByRef $hMxCtrlDetails, $iFlags)
DllStructSetData($hMxCtrlDetails, $MCD_CBSTRUCT, DllStructGetSize($hMxCtrlDetails))
Local $iRet = DllCall("winmm.dll", "uint", "mixerSetControlDetails", "uint", $hMixer, "ptr", DllStructGetPtr($hMxCtrlDetails), "dword", $iFlags)
If @error Or $iRet[0] Then
Return False
Else
Return True
EndIf
EndFunc ;==>MixerSetControlDetails
Func MixerSetGet($iMixerID, $sComponentType, $iComponentInstance, $sControlType, $fIsSet, $iNewParamValue)
;verifica Id
If Not IsInt($iMixerID) Or $iMixerID < 0 Then
SetError(1)
Return 0
EndIf
;determina o tipo de componente
Local $iComponentType = -1
For $iIndex = 0 To UBound($asComponentTypes) - 1
If StringCompare($sComponentType, $asComponentTypes[$iIndex]) = 0 Then
$iComponentType = $aiComponentTypes[$iIndex]
ExitLoop
EndIf
Next
; verifica tipo de componente
If $iComponentType = -1 Then
SetError(2)
Return 0
EndIf
; verifica instância do componente
If Not IsInt($iComponentInstance) Or $iComponentInstance <= 0 Then
SetError(3)
Return 0
EndIf
; Determina o tipo de controle
Local $iControlType = -1
For $iIndex = 0 To UBound($asControlTypes) - 1
If StringCompare($sControlType, $asControlTypes[$iIndex]) = 0 Then
$iControlType = $aiControlTypes[$iIndex]
ExitLoop
EndIf
Next
If $iControlType = -1 Then
SetError(4)
Return 0
EndIf
;abre o Mixer especificado
Local $hMixer
If Not MixerOpen($hMixer, $iMixerID, 0, 0, 0) Then
SetError(5)
Return 0
EndIf
Local $iDestCount
Local $hMxCaps = DllStructCreate($MCA_STRUCT_DEF)
If MixerGetDevCaps($hMixer, $hMxCaps) Then
$iDestCount = DllStructGetData($hMxCaps, $MCA_CDESTINATIONS)
Else
$iDestCount = 1
EndIf
Local $hMxLine = DllStructCreate($ML_STRUCT_DEF)
If $iComponentInstance = 1 Then
DllStructSetData($hMxLine, $ML_DWCOMPONENTTYPE, $iComponentType)
If Not MixerGetLineInfo($hMixer, $hMxLine, $MIXER_GETLINEINFOF_COMPONENTTYPE) Then
MixerClose($hMixer)
SetError(6)
Return 0
EndIf
Else
Local $fFound = False
Local $iCurDest = 0
Local $iInstanceFound = 0
While $iCurDest < $iDestCount And Not $fFound
DllStructSetData($hMxLine, $ML_DWDESTINATION, $iCurDest)
If Not MixerGetLineInfo($hMixer, $hMxLine, $MIXER_GETLINEINFOF_DESTINATION) Then
$iCurDest = $iCurDest + 1
ContinueLoop
EndIf
Local $iSrcCount = DllStructGetData($hMxLine, $ML_CCONNECTIONS)
Local $iCurSrc = 0
While $iCurSrc < $iSrcCount And Not $fFound
DllStructSetData($hMxLine, $ML_DWDESTINATION, $iCurDest)
DllStructSetData($hMxLine, $ML_DWSOURCE, $iCurSrc)
If Not MixerGetLineInfo($hMixer, $hMxLine, $MIXER_GETLINEINFOF_SOURCE) Then
$iCurSrc = $iCurSrc + 1
ContinueLoop
EndIf
If DllStructGetData($hMxLine, $ML_DWCOMPONENTTYPE) = $iComponentType Then
$iInstanceFound = $iInstanceFound + 1
If $iInstanceFound = $iComponentInstance Then
$fFound = True
EndIf
EndIf
$iCurSrc = $iCurSrc + 1
WEnd
$iCurDest = $iCurDest + 1
WEnd
If Not $fFound Then
MixerClose($hMixer)
SetError(7)
Return 0
EndIf
EndIf
Local $hMxLineCtrls = DllStructCreate($MLC_STRUCT_DEF)
Local $hMxCtrl = DllStructCreate($MCO_STRUCT_DEF)
DllStructSetData($hMxLineCtrls, $MLC_CBSTRUCT, DllStructGetSize($hMxLineCtrls))
DllStructSetData($hMxLineCtrls, $MLC_DWLINEID, DllStructGetData($hMxLine, $ML_DWLINEID))
DllStructSetData($hMxLineCtrls, $MLC_DWCONTROLTYPE, $iControlType)
DllStructSetData($hMxLineCtrls, $MLC_CCONTROLS, 1)
DllStructSetData($hMxLineCtrls, $MLC_CBMXCTRL, DllStructGetSize($hMxCtrl))
DllStructSetData($hMxLineCtrls, $MLC_PAMXCTRL, DllStructGetPtr($hMxCtrl))
If Not MixerGetLineControls($hMixer, $hMxLineCtrls, $MIXER_GETLINECONTROLSF_ONEBYTYPE) Then
MixerClose($hMixer)
SetError(8)
Return 0
EndIf
Local $iMin = DllStructGetData($hMxCtrl, $MCO_DWMINIMUM)
Local $iMax = DllStructGetData($hMxCtrl, $MCO_DWMAXIMUM)
Local $fControlTypeIsBoolean
Switch $iControlType
Case $MIXERCONTROL_CONTROLTYPE_ONOFF
$fControlTypeIsBoolean = True
Case $MIXERCONTROL_CONTROLTYPE_MUTE
$fControlTypeIsBoolean = True
Case $MIXERCONTROL_CONTROLTYPE_MONO
$fControlTypeIsBoolean = True
Case $MIXERCONTROL_CONTROLTYPE_LOUDNESS
$fControlTypeIsBoolean = True
Case $MIXERCONTROL_CONTROLTYPE_STEREOENH
$fControlTypeIsBoolean = True
Case Else
$fControlTypeIsBoolean = False
EndSwitch
Local $fAdjustCurrentSettings = False
If $fIsSet And (StringLeft($iNewParamValue, 1) = "+" Or StringLeft($iNewParamValue, 1) = "-") Then
$fAdjustCurrentSettings = True
EndIf
Local $hMxCtrlDetails = DllStructCreate($MCD_STRUCT_DEF)
Local $hMxCtrlValue = DllStructCreate($MCDU_STRUCT_DEF)
DllStructSetData($hMxCtrlDetails, $MCD_CBSTRUCT, DllStructGetSize($hMxCtrlDetails))
DllStructSetData($hMxCtrlDetails, $MCD_DWCONTROLID, DllStructGetData($hMxCtrl, $MCO_DWCONTROLID))
DllStructSetData($hMxCtrlDetails, $MCD_CCHANNELS, 1)
DllStructSetData($hMxCtrlDetails, $MCD_CBDETAILS, DllStructGetSize($hMxCtrlValue))
DllStructSetData($hMxCtrlDetails, $MCD_PADETAILS, DllStructGetPtr($hMxCtrlValue))
Local $iCurValue = 0
If $fAdjustCurrentSettings Then
If Not MixerGetControlDetails($hMixer, $hMxCtrlDetails, $MIXER_GETCONTROLDETAILSF_VALUE) Then
MixerClose($hMixer)
SetError(9)
Return 0
EndIf
$iCurValue = DllStructGetData($hMxCtrlValue, $MCDU_DWVALUE)
EndIf
If $fIsSet Then
If $fControlTypeIsBoolean Then
If $fAdjustCurrentSettings Then
If $iCurValue > $iMin Then
DllStructSetData($hMxCtrlValue, $MCDU_DWVALUE, $iMin)
Else
DllStructSetData($hMxCtrlValue, $MCDU_DWVALUE, $iMax)
EndIf
Else
If $iNewParamValue > 0 Then
DllStructSetData($hMxCtrlValue, $MCDU_DWVALUE, $iMax)
Else
DllStructSetData($hMxCtrlValue, $MCDU_DWVALUE, $iMin)
EndIf
EndIf
Else
Local $iNewActualValue = ($iMax - $iMin) * ($iNewParamValue / 100.0)
If $fAdjustCurrentSettings Then
$iNewActualValue = $iNewActualValue + $iCurValue
EndIf
If $iNewActualValue < $iMin Then
$iNewActualValue = $iMin
ElseIf $iNewActualValue > $iMax Then
$iNewActualValue = $iMax
EndIf
DllStructSetData($hMxCtrlValue, $MCDU_DWVALUE, $iNewActualValue)
EndIf
If Not MixerSetControlDetails($hMixer, $hMxCtrlDetails, $MIXER_SETCONTROLDETAILSF_VALUE) Then
MixerClose($hMixer)
SetError(10)
Return 0
EndIf
EndIf
If Not MixerGetControlDetails($hMixer, $hMxCtrlDetails, $MIXER_GETCONTROLDETAILSF_VALUE) Then
MixerClose($hMixer)
SetError(9)
Return 0
EndIf
$iCurValue = DllStructGetData($hMxCtrlValue, $MCDU_DWVALUE)
MixerClose($hMixer)
SetError(0)
If $fControlTypeIsBoolean Then
If $iCurValue Then
Return 1
Else
Return 0
EndIf
Else
Return Round(100.0 * ($iCurValue - $iMin) / ($iMax - $iMin), 2)
EndIf
EndFunc ;==>MixerSetGet
Note: I no longer remember where I got it and I also don't know the author's name.