Jump to content

Query and set microphone mute status


Recommended Posts

Hi,

i'm looking for a command or something similar to use an AutoIT script to check if the active microphone is muted (in Windows 10).
 

Unfortunately I couldn't find much, the closest to it seems to be this script: Sound-enable-disable
The script only lists some devices which do not look like to be my mics and nothing is muted.

I also found infos that it is possible to see and change the status in the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\MMMDevices\Audio\Capture

But no matter what I do, nothing changes and a change of the Registry values has no effect.

Under Control Panel --> Sound --> Recording --> Microphone --> Level you can click on the speaker icon, then it is muted.
Unfortunately I could not find out what is happening in the background with Process Explorer.
After clicking the symbol is crossed out and shows the mute state, but obviously not in general.

Mic.png.f9e6d5be1a2cbe831d3816424a64a319.png

If I press the mute button on my headset, this symbol does not change, but I am muted.
If I press the above mentioned button, my headset also mutes (Jabra Engage 75).

Does anyone know of a way to check and change the mute status of all (or just the active) microphones?

Link to comment
Share on other sites

I figure that getting the information from windows can be done, in the registry key you mentioned, changing, not so easy.

Anyway one option i could give a shot would be to go with the bass libraries and set up the recording function, maybe one of the functions can check if a microphone is active at all, or maybe the script could try capture sound, and if no sound at all is captured, assume is muted.

This thing you're messing with is a mess imo, i tried to do a default playback device change and it was a mess, had to resort to automate the windows and to the clicks as if im doing it myself, clicking and all.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

You can use this script to query/set microphone by going thru systray options.  You need to provide all 3 strings that defines your systray sound button (button, device type, and device). I gave you french version.  The speaker button needs to be visible. Tested on win7.

#NoTrayIcon
#include "Includes\CUIAutomation2.au3"
#include <Constants.au3>
#include <Array.au3>

Opt("MustDeclareVars", 1)

Local $aMenu = _Systray_SelectOption("Haut-parleurs", "Périphériques d’enregistrement", "Microphone")
If IsArray ($aMenu) Then _ArrayDisplay ($aMenu)

Func _Systray_SelectOption($sButton, $sDeviceType, $sDevice)
  Local $hWnd = WinGetHandle('[Class:Shell_TrayWnd]')
  If Not $hWnd Then Return SetError(1)

  Local $hCtrl = ControlGetHandle($hWnd, '', "ToolbarWindow321") ; must be visible
  If Not $hCtrl Then Return SetError(2)

  ; Create UI Automation object
  Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation)
  If Not IsObj($oUIAutomation) Then Return ConsoleWrite("$oUIAutomation ERR" & @CRLF)
  ConsoleWrite("$oUIAutomation OK" & @CRLF)

  ; Get Desktop element
  Local $pDesktop, $oDesktop
  $oUIAutomation.GetRootElement($pDesktop)
  $oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oDesktop) Then Return ConsoleWrite("$oDesktop ERR" & @CRLF)
  ConsoleWrite("$oDesktop OK" & @CRLF)

  ; Get element by handle
  Local $pElement, $oElement
  $oUIAutomation.ElementFromHandle($hCtrl, $pElement)
  $oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oElement) Then Return ConsoleWrite("$oElement ERR" & @CRLF)
  ConsoleWrite("$oElement OK" & @CRLF)

  ; Get condition (ControlType = Button)
  Local $pCondition, $oCondition
  $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition)
  $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
  If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF)
  ConsoleWrite("$oCondition OK" & @CRLF)

  ; Find all buttons
  Local $pElementArray, $oElementArray, $iElements
  $oElement.FindAll($TreeScope_Children, $oCondition, $pElementArray)
  $oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray)
  $oElementArray.Length($iElements)
  If Not IsObj($oElementArray) Then Return ConsoleWrite("$oElementArray ERR" & @CRLF)
  ConsoleWrite("$oElementArray OK" & @CRLF)

  ; Get array of buttons
  Local $aElements[$iElements]
  For $i = 0 To $iElements - 1
    $oElementArray.GetElement($i, $pElement)
    $aElements[$i] = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  Next

  ; Get name and position for each button
  Local $vValue, $aPos, $bFound = False
  Local $tRect = DllStructCreate("long Left;long Top;long Right;long Bottom")
  Local $tPoint = DllStructCreate("long X;long Y"), $bBool, $oSound
  For $i = 0 To UBound($aElements) - 1
    $aElements[$i].GetCurrentPropertyValue($UIA_NamePropertyId, $vValue)
    ConsoleWrite("Name:" & $vValue)
    $aElements[$i].CurrentBoundingRectangle($tRect)
    ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF)
    $aElements[$i].GetClickablePoint($tPoint, $bBool)
    If StringInStr($vValue, $sButton) Then
      MouseClick("Right", $tPoint.X, $tPoint.Y, 1, 1)
      $bFound = True
      $oSound = $aElements[$i]
      ExitLoop
    EndIf
  Next

  Sleep(1500)

  $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "#32768", $pCondition)
  If Not $pCondition Then Return ConsoleWrite("$pCondition ERR" & @CRLF)
  ConsoleWrite("$pCondition OK" & @CRLF)

  Local $pSound, $oObject
  $oDesktop.FindFirst($TreeScope_Descendants, $pCondition, $pSound)
  $oObject = ObjCreateInterface($pSound, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oObject) Then Return ConsoleWrite("$oObject ERR" & @CRLF)
  ConsoleWrite("$oObject OK" & @CRLF)

  $oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, $sDeviceType, $pCondition)
  $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
  If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF)
  ConsoleWrite("$oCondition OK" & @CRLF)

  $oObject.FindFirst($TreeScope_Descendants, $pCondition, $pSound)
  $oSound = ObjCreateInterface($pSound, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oSound) Then Return ConsoleWrite("$oSound ERR" & @CRLF)
  ConsoleWrite("$oSound OK" & @CRLF)

  $oSound.GetCurrentPropertyValue($UIA_NamePropertyId, $vValue)
  ConsoleWrite("Name:" & $vValue)
  $oSound.CurrentBoundingRectangle($tRect)
  ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF)
  $oSound.GetClickablePoint($tPoint, $bBool)
  MouseClick("left", $tPoint.X, $tPoint.Y, 1, 1)

  Sleep (1500)

  $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "#32770", $pCondition)
  $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
  If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF)
  ConsoleWrite("$oCondition OK" & @CRLF)

  $oDesktop.FindFirst($TreeScope_Children, $oCondition, $pElement)
  $oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oElement) Then Return ConsoleWrite("$oElement ERR" & @CRLF)
  ConsoleWrite("$oElement OK" & @CRLF)

  $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "SysListView32", $pCondition)
  $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
  If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF)
  ConsoleWrite("$oCondition OK" & @CRLF)

  $oElement.FindFirst($TreeScope_Children, $oCondition, $pElement)
  $oObject = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oObject) Then Return ConsoleWrite("$oObject ERR" & @CRLF)
  ConsoleWrite("$oObject OK" & @CRLF)

  $oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, $sDevice, $pCondition)
  $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
  If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF)
  ConsoleWrite("$oCondition OK" & @CRLF)

  $oObject.FindFirst($TreeScope_Children, $oCondition, $pElement)
  $oSound = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oSound) Then Return ConsoleWrite("$oSound ERR" & @CRLF)
  ConsoleWrite("$oSound OK" & @CRLF)

  $oSound.GetCurrentPropertyValue($UIA_NamePropertyId, $vValue)
  ConsoleWrite("Name:" & $vValue)
  $oSound.CurrentBoundingRectangle($tRect)
  ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF)
  $oSound.GetClickablePoint($tPoint, $bBool)
  MouseClick ("Right", $tPoint.X, $tPoint.Y+10, 1, 1)

  Sleep (1000)

  $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "#32768", $pCondition)
  If Not $pCondition Then Return ConsoleWrite("$pCondition ERR" & @CRLF)
  ConsoleWrite("$pCondition OK" & @CRLF)

  $oDesktop.FindFirst($TreeScope_Descendants, $pCondition, $pSound)
  $oObject = ObjCreateInterface($pSound, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oObject) Then Return ConsoleWrite("$oObject ERR" & @CRLF)
  ConsoleWrite("$oObject OK" & @CRLF)

 ; Get condition (ControlType = Menu Items)
  $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_MenuItemControlTypeId, $pCondition)
  $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
  If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF)
  ConsoleWrite("$oCondition OK" & @CRLF)

  ; Find all menu items
  $oObject.FindAll($TreeScope_Children, $oCondition, $pElementArray)
  $oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray)
  $oElementArray.Length($iElements)
  If Not IsObj($oElementArray) Then Return ConsoleWrite("$oElementArray ERR" & @CRLF)
  ConsoleWrite("$oElementArray OK" & @CRLF)

  ; Get array of menu items
  Local $aElements[$iElements][4]
  For $i = 0 To $iElements - 1
    $oElementArray.GetElement($i, $pElement)
    $aElements[$i][0] = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  Next

  ; Get name and position for each menu items
  For $i = 0 To $iElements - 1
    $aElements[$i][0].GetCurrentPropertyValue($UIA_NamePropertyId, $vValue)
    ConsoleWrite("Name:" & $vValue)
    $aElements[$i][1] = $vValue
    $aElements[$i][0].CurrentBoundingRectangle($tRect)
    ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF)
    $aElements[$i][0].GetClickablePoint($tPoint, $bBool)
    $aElements[$i][2] = $tPoint.X
    $aElements[$i][3] = $tPoint.Y
  Next
  Return $aElements
EndFunc   ;==>_Systray_SelectOption

 

Link to comment
Share on other sites

On 5/6/2020 at 5:14 AM, careca said:

I figure that getting the information from windows can be done, in the registry key you mentioned, changing, not so easy.

Anyway one option i could give a shot would be to go with the bass libraries and set up the recording function, maybe one of the functions can check if a microphone is active at all, or maybe the script could try capture sound, and if no sound at all is captured, assume is muted.

This thing you're messing with is a mess imo, i tried to do a default playback device change and it was a mess, had to resort to automate the windows and to the clicks as if im doing it myself, clicking and all.

Thanks, i will try Bass UDF, very huge, this will take some time...

 

23 hours ago, Nine said:

You can use this script to query/set microphone by going thru systray options.  You need to provide all 3 strings that defines your systray sound button (button, device type, and device). I gave you french version.  The speaker button needs to be visible. Tested on win7.

#NoTrayIcon
#include "Includes\CUIAutomation2.au3"
#include <Constants.au3>
#include <Array.au3>

Opt("MustDeclareVars", 1)

Local $aMenu = _Systray_SelectOption("Haut-parleurs", "Périphériques d’enregistrement", "Microphone")
If IsArray ($aMenu) Then _ArrayDisplay ($aMenu)

Func _Systray_SelectOption($sButton, $sDeviceType, $sDevice)
  Local $hWnd = WinGetHandle('[Class:Shell_TrayWnd]')
  If Not $hWnd Then Return SetError(1)

  Local $hCtrl = ControlGetHandle($hWnd, '', "ToolbarWindow321") ; must be visible
  If Not $hCtrl Then Return SetError(2)

  ; Create UI Automation object
  Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation)
  If Not IsObj($oUIAutomation) Then Return ConsoleWrite("$oUIAutomation ERR" & @CRLF)
  ConsoleWrite("$oUIAutomation OK" & @CRLF)

  ; Get Desktop element
  Local $pDesktop, $oDesktop
  $oUIAutomation.GetRootElement($pDesktop)
  $oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oDesktop) Then Return ConsoleWrite("$oDesktop ERR" & @CRLF)
  ConsoleWrite("$oDesktop OK" & @CRLF)

  ; Get element by handle
  Local $pElement, $oElement
  $oUIAutomation.ElementFromHandle($hCtrl, $pElement)
  $oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oElement) Then Return ConsoleWrite("$oElement ERR" & @CRLF)
  ConsoleWrite("$oElement OK" & @CRLF)

  ; Get condition (ControlType = Button)
  Local $pCondition, $oCondition
  $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition)
  $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
  If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF)
  ConsoleWrite("$oCondition OK" & @CRLF)

  ; Find all buttons
  Local $pElementArray, $oElementArray, $iElements
  $oElement.FindAll($TreeScope_Children, $oCondition, $pElementArray)
  $oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray)
  $oElementArray.Length($iElements)
  If Not IsObj($oElementArray) Then Return ConsoleWrite("$oElementArray ERR" & @CRLF)
  ConsoleWrite("$oElementArray OK" & @CRLF)

  ; Get array of buttons
  Local $aElements[$iElements]
  For $i = 0 To $iElements - 1
    $oElementArray.GetElement($i, $pElement)
    $aElements[$i] = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  Next

  ; Get name and position for each button
  Local $vValue, $aPos, $bFound = False
  Local $tRect = DllStructCreate("long Left;long Top;long Right;long Bottom")
  Local $tPoint = DllStructCreate("long X;long Y"), $bBool, $oSound
  For $i = 0 To UBound($aElements) - 1
    $aElements[$i].GetCurrentPropertyValue($UIA_NamePropertyId, $vValue)
    ConsoleWrite("Name:" & $vValue)
    $aElements[$i].CurrentBoundingRectangle($tRect)
    ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF)
    $aElements[$i].GetClickablePoint($tPoint, $bBool)
    If StringInStr($vValue, $sButton) Then
      MouseClick("Right", $tPoint.X, $tPoint.Y, 1, 1)
      $bFound = True
      $oSound = $aElements[$i]
      ExitLoop
    EndIf
  Next

  Sleep(1500)

  $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "#32768", $pCondition)
  If Not $pCondition Then Return ConsoleWrite("$pCondition ERR" & @CRLF)
  ConsoleWrite("$pCondition OK" & @CRLF)

  Local $pSound, $oObject
  $oDesktop.FindFirst($TreeScope_Descendants, $pCondition, $pSound)
  $oObject = ObjCreateInterface($pSound, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oObject) Then Return ConsoleWrite("$oObject ERR" & @CRLF)
  ConsoleWrite("$oObject OK" & @CRLF)

  $oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, $sDeviceType, $pCondition)
  $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
  If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF)
  ConsoleWrite("$oCondition OK" & @CRLF)

  $oObject.FindFirst($TreeScope_Descendants, $pCondition, $pSound)
  $oSound = ObjCreateInterface($pSound, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oSound) Then Return ConsoleWrite("$oSound ERR" & @CRLF)
  ConsoleWrite("$oSound OK" & @CRLF)

  $oSound.GetCurrentPropertyValue($UIA_NamePropertyId, $vValue)
  ConsoleWrite("Name:" & $vValue)
  $oSound.CurrentBoundingRectangle($tRect)
  ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF)
  $oSound.GetClickablePoint($tPoint, $bBool)
  MouseClick("left", $tPoint.X, $tPoint.Y, 1, 1)

  Sleep (1500)

  $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "#32770", $pCondition)
  $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
  If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF)
  ConsoleWrite("$oCondition OK" & @CRLF)

  $oDesktop.FindFirst($TreeScope_Children, $oCondition, $pElement)
  $oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oElement) Then Return ConsoleWrite("$oElement ERR" & @CRLF)
  ConsoleWrite("$oElement OK" & @CRLF)

  $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "SysListView32", $pCondition)
  $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
  If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF)
  ConsoleWrite("$oCondition OK" & @CRLF)

  $oElement.FindFirst($TreeScope_Children, $oCondition, $pElement)
  $oObject = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oObject) Then Return ConsoleWrite("$oObject ERR" & @CRLF)
  ConsoleWrite("$oObject OK" & @CRLF)

  $oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, $sDevice, $pCondition)
  $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
  If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF)
  ConsoleWrite("$oCondition OK" & @CRLF)

  $oObject.FindFirst($TreeScope_Children, $oCondition, $pElement)
  $oSound = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oSound) Then Return ConsoleWrite("$oSound ERR" & @CRLF)
  ConsoleWrite("$oSound OK" & @CRLF)

  $oSound.GetCurrentPropertyValue($UIA_NamePropertyId, $vValue)
  ConsoleWrite("Name:" & $vValue)
  $oSound.CurrentBoundingRectangle($tRect)
  ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF)
  $oSound.GetClickablePoint($tPoint, $bBool)
  MouseClick ("Right", $tPoint.X, $tPoint.Y+10, 1, 1)

  Sleep (1000)

  $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "#32768", $pCondition)
  If Not $pCondition Then Return ConsoleWrite("$pCondition ERR" & @CRLF)
  ConsoleWrite("$pCondition OK" & @CRLF)

  $oDesktop.FindFirst($TreeScope_Descendants, $pCondition, $pSound)
  $oObject = ObjCreateInterface($pSound, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  If Not IsObj($oObject) Then Return ConsoleWrite("$oObject ERR" & @CRLF)
  ConsoleWrite("$oObject OK" & @CRLF)

 ; Get condition (ControlType = Menu Items)
  $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_MenuItemControlTypeId, $pCondition)
  $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
  If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF)
  ConsoleWrite("$oCondition OK" & @CRLF)

  ; Find all menu items
  $oObject.FindAll($TreeScope_Children, $oCondition, $pElementArray)
  $oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray)
  $oElementArray.Length($iElements)
  If Not IsObj($oElementArray) Then Return ConsoleWrite("$oElementArray ERR" & @CRLF)
  ConsoleWrite("$oElementArray OK" & @CRLF)

  ; Get array of menu items
  Local $aElements[$iElements][4]
  For $i = 0 To $iElements - 1
    $oElementArray.GetElement($i, $pElement)
    $aElements[$i][0] = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  Next

  ; Get name and position for each menu items
  For $i = 0 To $iElements - 1
    $aElements[$i][0].GetCurrentPropertyValue($UIA_NamePropertyId, $vValue)
    ConsoleWrite("Name:" & $vValue)
    $aElements[$i][1] = $vValue
    $aElements[$i][0].CurrentBoundingRectangle($tRect)
    ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF)
    $aElements[$i][0].GetClickablePoint($tPoint, $bBool)
    $aElements[$i][2] = $tPoint.X
    $aElements[$i][3] = $tPoint.Y
  Next
  Return $aElements
EndFunc   ;==>_Systray_SelectOption

 

If i cant figure out Bass UDF, i will try this, but i prefer a more stable solution.

Link to comment
Share on other sites

One function that would probably help is _BASS_RecordGetDeviceInfo, but i understand, it is a bit complex.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Hello. You can do something like this.

 

Opt("MustDeclareVars", 1)

Global Enum $eRender, $eCapture, $eAll, $EDataFlow_enum_count
;~ AudioSessionState
Global Const $CLSCTX_INPROC_SERVER = 0x01
Global Const $eMultimedia = 1

Global Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}"
Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}"
Global Const $sTagIMMDeviceEnumerator = _
        "EnumAudioEndpoints hresult(int;dword;ptr*);" & _
        "GetDefaultAudioEndpoint hresult(int;int;ptr*);" & _
        "GetDevice hresult(wstr;ptr*);" & _
        "RegisterEndpointNotificationCallback hresult(ptr);" & _
        "UnregisterEndpointNotificationCallback hresult(ptr)"


Global Const $sIID_IMMDevice = "{D666063F-1587-4E43-81F1-B948E807363F}"
Global Const $sTagIMMDevice = _
        "Activate hresult(struct*;dword;ptr;ptr*);" & _
        "OpenPropertyStore hresult(dword;ptr*);" & _
        "GetId hresult(wstr*);" & _
        "GetState hresult(dword*)"


Global Const $sIID_IAudioSessionEnumerator = "{e2f5bb11-0570-40ca-acdd-3aa01277dee8}"
Global Const $sTagIAudioSessionEnumerator = "GetCount hresult(int*);GetSession hresult(int;ptr*)"


Global Const $sIID_IAudioEndpointVolume = "{5CDF2C82-841E-4546-9722-0CF74078229A}"
Global Const $sTagIAudioEndpointVolume = _
        "RegisterControlChangeNotify hresult(ptr);" & _
        "UnregisterControlChangeNotify hresult(ptr);" & _
        "GetChannelCount hresult(uint*);" & _
        "SetMasterVolumeLevel hresult(float;ptr);" & _
        "SetMasterVolumeLevelScalar hresult(float;ptr);" & _
        "GetMasterVolumeLevel hresult(float*);" & _
        "GetMasterVolumeLevelScalar hresult(float*);" & _
        "SetChannelVolumeLevel hresult(uint;float;ptr);" & _
        "SetChannelVolumeLevelScalar hresult(uint;float;ptr);" & _
        "GetChannelVolumeLevel hresult(uint;float*);" & _
        "GetChannelVolumeLevelScalar hresult(uint;float*);" & _
        "SetMute hresult(int;ptr);" & _
        "GetMute hresult(int*);" & _
        "GetVolumeStepInfo hresult(uint*;uint*);" & _
        "VolumeStepUp hresult(ptr);" & _
        "VolumeStepDown hresult(ptr);" & _
        "QueryHardwareSupport hresult(dword*);" & _
        "GetVolumeRange hresult(float*;float*;float*)"


Local $pIMMDevice = 0
Local $oMMDevice = 0

Local $oMMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $sTagIMMDeviceEnumerator)
If Not IsObj($oMMDeviceEnumerator) Then Exit
If FAILED($oMMDeviceEnumerator.GetDefaultAudioEndpoint($eCapture, $eMultimedia, $pIMMDevice)) Then Exit
ConsoleWrite("$pIMMDevice: " & $pIMMDevice & @CRLF)


$oMMDevice = ObjCreateInterface($pIMMDevice, $sIID_IMMDevice, $sTagIMMDevice)
If Not IsObj($oMMDevice) Then Exit
ConsoleWrite("IsObj($oMMDevice): " & IsObj($oMMDevice) & @CRLF)

Local $pIAudioEndpointVolume = 0
Local $oIAudioEndpointVolume = 0
If FAILED($oMMDevice.Activate(__uuidof($sIID_IAudioEndpointVolume), $CLSCTX_INPROC_SERVER, 0, $pIAudioEndpointVolume)) Then Exit
ConsoleWrite("$pIAudioEndpointVolume: " & $pIAudioEndpointVolume & @CRLF)
$oIAudioEndpointVolume = ObjCreateInterface($pIAudioEndpointVolume, $sIID_IAudioEndpointVolume, $sTagIAudioEndpointVolume)
ConsoleWrite("IsObj($oIAudioEndpointVolume): " & IsObj($oIAudioEndpointVolume) & @CRLF)

Local $bMute = 0
$oIAudioEndpointVolume.GetMute($bMute)
ConsoleWrite("Mute: " & $bMute & @CRLF)
Sleep(3000)
$bMute = $bMute ? 0 : 1 ;Set Mute Exchange State
ConsoleWrite("Set Mute To: " & $bMute & @CRLF)
$oIAudioEndpointVolume.SetMute($bMute, 0)
Exit


Func FAILED($hr)
    Return ($hr < 0)
EndFunc   ;==>FAILED

Func __uuidof($sGUID)
    Local $tGUID = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]")
    DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sGUID, "struct*", $tGUID)
    If @error Then Return SetError(@error, @extended, 0)
    Return $tGUID
EndFunc   ;==>__uuidof

 

 


Saludos

 

 

 

Edited by Danyfirex
Edit
Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...