Hab mal die Erweiterung für MIC gemacht, einfach über CheckBox auf Mikro switchen.
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <WindowsConstants.au3>
#include <audio.au3>
Opt("GUIOnEventMode", 1)
HotKeySet("^+{F6}", "_exitVol")
Global $pos1[2] = [@DesktopWidth-3, @DesktopHeight/2 -108]
Global $pos2[2] = [@DesktopWidth-43, @DesktopHeight/2 -108]
Global $moved = False
$guiSpeaker = GUICreate("PC", 38, 256, $pos1[0], $pos1[1], BitOR($WS_MINIMIZEBOX,$WS_CAPTION, _
$WS_POPUP,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS))
$slVol = GUICtrlCreateSlider(8, 16, 20, 150, BitOR($TBS_VERT,$TBS_TOP,$TBS_LEFT,$TBS_NOTICKS))
GUICtrlSetOnEvent(-1, "slVolChange")
GUICtrlSetData(-1, 100-_SoundGetMasterVolume())
$cbMute = GUICtrlCreateCheckbox("", 11, 173, 17, 17)
GUICtrlSetOnEvent(-1, "cbMuteClick")
If _isMute() Then
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetState($slVol, $GUI_DISABLE)
EndIf
$Label1 = GUICtrlCreateLabel("Aus", 9, 194, 22, 17)
$cbMic = GUICtrlCreateCheckbox("", 11, 215, 17, 17)
GUICtrlSetOnEvent(-1, "cbMicClick")
$LabelMic = GUICtrlCreateLabel("Mic", 9, 234, 22, 17)
GUISetState(@SW_SHOW)
While 1
Sleep(100)
_checkPos()
WEnd
Func _exitVol()
Exit
EndFunc
Func cbMuteClick()
Local $id
If BitAND(GUICtrlRead($cbMic), $GUI_CHECKED) Then
$id = 5000
Else
$id = 1000
EndIf
If BitAND(GUICtrlRead($cbMute), $GUI_CHECKED) Then
GUICtrlSetState($slVol, $GUI_DISABLE)
_MuteVol($id)
Else
GUICtrlSetState($slVol, $GUI_ENABLE)
_UnMuteVol($id)
EndIf
EndFunc
Func cbMicClick()
If BitAND(GUICtrlRead($cbMic), $GUI_CHECKED) Then
WinSetTitle($guiSpeaker, '', 'MIC')
If Not _isMute(5000) Then
GUICtrlSetState($cbMute, $GUI_UNCHECKED)
Else
GUICtrlSetState($cbMute, $GUI_CHECKED)
EndIf
GUICtrlSetData($slVol, 100-_SoundGetMicrophoneVolume())
Else
WinSetTitle($guiSpeaker, '', 'PC')
If Not _isMute() Then
GUICtrlSetState($cbMute, $GUI_UNCHECKED)
Else
GUICtrlSetState($cbMute, $GUI_CHECKED)
EndIf
GUICtrlSetData($slVol, 100-_SoundGetMasterVolume())
EndIf
EndFunc
Func slVolChange()
If BitAND(GUICtrlRead($cbMic), $GUI_CHECKED) Then
_SoundSetMicrophoneVolume(100- GUICtrlRead($slVol))
Else
_SoundSetMasterVolume(100- GUICtrlRead($slVol))
EndIf
EndFunc
Func _checkPos()
Local $mouse = MouseGetPos()
If ($mouse[0] > $pos1[0]) Then
WinMove($guiSpeaker, '', $pos2[0], $pos2[1])
$moved = True
ElseIf $moved And ($mouse[0] < $pos1[0]-50) Then
WinMove($guiSpeaker, '', $pos1[0], $pos1[1])
$moved = False
EndIf
EndFunc
Func _MuteVol($opt = 1000)
Local $retVal = 0, $ex = False
If Not WinExists('[CLASS:Volume Control]') Then
Run('sndvol32', '', @SW_HIDE)
$ex = True
EndIf
If WinWait('[CLASS:Volume Control]', '', 2) = 0 Then Return -1
$retVal = ControlCommand('[CLASS:Volume Control]', '', $opt, 'isChecked')
If @error Then Return -2
If Not $retVal Then
ControlCommand('[CLASS:Volume Control]', '', $opt, 'Check')
If @error Then Return -2
EndIf
If $ex = True Then WinClose('[CLASS:Volume Control]')
Return
EndFunc ;==>_MuteVol
Func _UnMuteVol($opt = 1000)
Local $retVal = 0, $ex = False
If Not WinExists('[CLASS:Volume Control]') Then
Run('sndvol32', '', @SW_HIDE)
$ex = True
EndIf
If WinWait('[CLASS:Volume Control]', '', 2) = 0 Then Return -1
$retVal = ControlCommand('[CLASS:Volume Control]', '', $opt, 'isChecked')
If @error Then Return -2
If $retVal Then
ControlCommand('[CLASS:Volume Control]', '', $opt, 'UnCheck')
If @error Then Return -2
EndIf
If $ex = True Then WinClose('[CLASS:Volume Control]')
Return
EndFunc ;==>_UnMuteVol