#cs ======================================================================================== Scripted in ....: AutoIt v3.3.16.1 Scripted on ....: Windows 11 v24H2 Scripted File ..: MuteCheckerV100.au3 Scrip Editor ...: NotePad v11.2410.21.0 NotePad Font ...: [Consolas Regular 12] --------------------------------------------------------------------------------------- Date Started v1 : [01.21.2025] Last Updated v1 : [02.06.2025] Total Lines.....: 162 (Code & Comments!) --------------------------------------------------------------------------------------- Purpose ........: Created to Auto Select and Auto Unmute Playback Devices. Remarks ........: Auto opens Window's SoundTool (WinTitle: "Sound"). Remarks ........: Auto selects the 1st Playback Device in the List. Remarks ........: To Auto select ALL Devices in List use the For/Next Loop. Remarks ........: Auto opens the selected Device's Properties Window. Remarks ........: Searches for the Tab that contains Control-ID 1512 (&Mute). Remarks ........: Checks the status of the &Mute Button (Checked = Device is Muted). Remarks ........: IF Button is Checked then: Sent One Click to Unmute the Device! Remarks ........: Closes SoundTool and then displays the Mute Button Scan(s) Results. Author .........: Jeffrey Lee Treat #ce ======================================================================================== ;------------------------------------------------------------------------------------------- #include #include #include ;------------------------------------------------------------------------------------------- ; ___________________________________________________________________ ; __________________________________________ ; Global $ProgName = "MuteChecker" Global $ProgVers = "v100" Global $ProgramN = $ProgName&" "&$ProgVers Global $ConHdBn2 = 0 ;------------------------------------> Control Handle: (for Button) #2 Global $IsMuteCk = 0 ;------------------------------------> Is Muted Checked? 1=Yes / 0=No Global $OneFound = 0 ;------------------------------------> One (or more) Buttons Found Checked Global $ProcessN = 0 ;------------------------------------> Process (ID) Number: PID of Window Global $SoundPID = 0 ;------------------------------------> SoundTool Process ID (PID) (Sound) Global $RunCPT01 = "Control mmsys.cpl" ;------------------> Run Contol Panel Tool (01=Sound) Global $SoundTT1 = "Sound" ;------------------------------> SoundTool Title 1 (Main window!) Global $SoundTT2 = "Properties" ;-------------------------> SoundTool Title 2 (Child window) Global $SWHandle = 0 ;------------------------------------> Sound (Main!) Window Handle Global $CWHandle = 0 ;------------------------------------> Sound (Child) Window Handle Global $ListHand = 0 ;------------------------------------> List Handle of List (in Sound Window) Global $ListTotl = 0 ;------------------------------------> List Total! (Total PBk-Devices found) Global $ItemLoop = 0 ;------------------------------------> Item Loop Number (Row Num# of Device) Global $TabsLoop = 0 ;------------------------------------> Tabs Loop Number (The Tab Number) Global $ClassN01 = "[CLASS:SysListView32; INSTANCE:1]" ;--> Class Name (Instance=1) ; ;------------------------------------------------------------------------------------------- ; $MsgBoxTx = "Run the MuteChecker Program?" $UserInpt = MsgBox(262180, $ProgramN&" - Run Program?", $MsgBoxTx, 30) If $UserInpt = 7 Or $UserInpt = -1 Then Exit ;------------> User clicked "No" or Mesg Timed-Out: Exit! $ProcessN = WinGetProcess($SoundTT1) If $ProcessN <> -1 Then ProcessClose($ProcessN) ;---------> Close SoundTool if it is currently running $SoundPID = Run($RunCPT01) ;------------------------------> Run Contol Panel Tool 01 (Opens SoundTool) If $SoundPID = 0 Then ;-----------------------------------> $SoundPID = 0 if SoundTool was NOT Started $MsgBoxTx = "Window's SoundTool could NOT be Started!" MsgBox(262160, $ProgramN& " - Program Halted!", $MsgBoxTx, 60) $MsgBoxTx = "Restarting the Computer may fix the problem." MsgBox(262208, $ProgramN& " - Try Restarting!", $MsgBoxTx, 30) Exit EndIf $SWHandle = WinWaitActive($SoundTT1, "", 3) ;-------------> Get Sound Window Handle! (SoundTool)! If $SWHandle = 0 Then ;-----------------------------------> $SWHandle = 0 IF Timeout is Detected! $MsgBoxTx = "Window's SoundTool could NOT be accessed!" MsgBox(262160, $ProgramN& " - Program Halted!", $MsgBoxTx, 60) $MsgBoxTx = "Restarting AudioSet Program may fix the problem!" MsgBox(262208, $ProgramN& " - Restart Program!", $MsgBoxTx, 30) Exit EndIf #cs -------------------------------------------------- The next 2 lines of code will get the Total Amount of Playback Devices that are in the SoundTool List That Total Number could be used in a For/Next Loop #ce -------------------------------------------------- $ListHand = ControlGetHandle($SWHandle, "", "[CLASS:SysListView32]") $ListTotl = _GUICtrlListView_GetItemCount($ListHand) ;;;;$MsgBoxTx = "Total Amount of Devices found in List = "&$ListTotl ;;;;MsgBox(64, $ProgramN& " - Total Amount Found!", $MsgBoxTx, 30) ; ; ++++++++++++ _CkMuteButtn() ;------------------------------------------> **** Check Mute Buttons Function **** ; ++++++++++++ ; #cs --------------------------------------------------- If the For/Next Loop is used in the _CkMuteButton() Function then -ALL- of the Playback Devices will be checked! So if used..Use the Remarked out Messages! #ce --------------------------------------------------- If $OneFound = 0 Then $MsgBoxTx = "Mute Button was Unchecked. No Changes Made!" ;;;;$MsgBoxTx = "ALL Mute Buttons were Unchecked. No Changes Made!" ;------------------------------------------------------------------------------------------- ElseIf $OneFound = 1 Then $MsgBoxTx = "Detected that Button was Checked! First"&@CRLF& _ "Playback Device in List is now: UnMuted!" ;;;;$MsgBoxTx = "Detected that One or More Buttons were Checked!"&@CRLF& _ "ALL Playback Devices in the List are now: UnMuted!" ;------------------------------------------------------------------------------------------- EndIf MsgBox(64, $ProgramN& " - Mute Button Results...", $MsgBoxTx, 60) $MsgBoxTx = "Program has Successfully Completed!" MsgBox(64, $ProgramN& " - Done!", $MsgBoxTx, 10) Exit ;----------------------------------------------------> End of Script!/Exit the Program! ; ; ****************************************************************************************** Func _CkMuteButtn() $ItemLoop = 0 ;-----------------------------------------------------------> 1st Item (Row) in List is -0- ;;;;----------------------------------------------------------------------------------------------------- ;;;;For $ItemLoop = 0 to $ListTotl - 1 ;--------------------------------------> [0]=First Item: (Row) in List ;;;;----------------------------------------------------------------------------------------------------- ControlListView($SWHandle, "", $ClassN01, "Select", $ItemLoop) ;------> Select an Item: (Row) in List ControlClick($SWHandle, "", 1003) ;-----------------------------------> Open Device Properties Window Opt("WinTitleMatchMode", 2) ;-----------------------------------------> 2=Set Match Mode to ANYString $CWHandle = WinWaitActive($SoundTT2, "", 3) ;-------------------------> Get Sound (Child) Wind Handle Opt("WinTitleMatchMode", 1) ;-----------------------------------------> 1=Set Match Mode to -Default- If $CWHandle = 0 Then SplashOff() WinClose($SWHandle) $MsgBoxTx = "Device's Properties Window could not be opened!" MsgBox(262160, $ProgramN& " - Program Halted!", $MsgBoxTx, 60) $MsgBoxTx = "Program's ""ControlClick"" Failed! Restart AudioSet!" MsgBox(262208, $ProgramN& " - Please Restart!", $MsgBoxTx, 30) Exit EndIf For $TabsLoop = 1 to 3 ;----------------------------------------------> Move to Tab that has: ID 1512 ControlCommand($CWHandle, "", "SysTabControl321", "TabRight") Sleep(100) ;------------------------------------------------------> After "TabRight" Slow dn Loop $IconBnTx = ControlGetText($CWHandle, "", 1512) ;-----------------> Get "Text" of Control ID 1512 If $IconBnTx = "&Mute" Then $IconBnTx = 1 ExitLoop EndIf $IconBnTx = 0 Next ;----------------------------------------------------------------> End Of TabsLoop (Nested Loop) If $IconBnTx = 0 Then SplashOff() $ProcessN = WinGetProcess($SoundTT1) If $ProcessN <> -1 Then ProcessClose($ProcessN) Send("{ESC 2}") ;-------------------------------------------------> Close any opened Property Window $MsgBoxTx = "Search within the Tabs for Button text (&Mute) has Failed!" MsgBox(262160, $ProgramN& " - Program Halted!", $MsgBoxTx, 30) $MsgBoxTx = "Possible cause of Failure: Auto-Timing-Error. Restart!" MsgBox(262208, $ProgramN& " - Restart AudioSet!", $MsgBoxTx, 60) Exit EndIf $ConHdBn2 = ControlGetHandle($CWHandle, "", 1512) ;-------------------> Get Control Handle of Icon Button ID 1512 $IsMuteCk = _GUICtrlButton_GetCheck($ConHdBn2) ;----------------------> Get status of Icon Button: Is it Checked? If $IsMuteCk = 1 Then ;-----------------------------------------------> If = 1 Then I-Button is presently Checked _GUICtrlButton_Click($ConHdBn2) ;---------------------------------> Send Left-Click to I-Button to Uncheck it Sleep(100) $OneFound = 1 ;---------------------------------------------------> One (or more) Buttons Found were Checked! EndIf ControlClick($CWHandle, "", 1) ;--------------------------------------> Left-Click Devices Properties [OK] Button Sleep(100) ;;;;----------------------------------------------------------------------------------------------------- ;;;;Next ;--------------------------------------------------------------------> End Of ItemLoop (-Main- Loop) ;;;;----------------------------------------------------------------------------------------------------- WinClose($SWHandle) ;-----------------------------------------------------> Close the SoundTool Window (Sound Window) EndFunc ; ==>_CkMuteButtn