Jump to content
Sign in to follow this  
reta

AutoIt "Audio Device Switcher" help!

Recommended Posts

reta

Hello!

Can someone help me split this code into two scripts that instead of toggling between the two options you see, each of the two individual scripts will set different sound devices depending on which one of the scripts I run.

I want the scripts to select only one sound device and when that devide is already set to default the script just closes the window or preferably doesn't open up the window in the first place.

Run("c:\windows\system32\control.exe mmsys.cpl")
 
WinWaitActive("Sound")
 
ControlListView("Sound", "", "SysListView321", "Select", 2) ;Select the first device in the list
$result = ControlCommand("Sound", "", "Button2", "IsEnabled", "") ;checks if Set As Default button is enabled
If $result Then
        ;if Set As Default is enabled we can enable this device
    ControlClick("Sound",  "", "Button2") ;Click Set As Default
    ControlClick("Sound", "", "Button4") ;Click OK
    Traytip("Audio Out", "Golvhögtalare, vardagsrum", 5, 1)
    Sleep(5000)
    Exit
EndIf
 
ControlListView("Sound", "", "SysListView321", "Select", 3) ;select the second device in the list
$result = ControlCommand("Sound", "", "Button2", "IsEnabled", "") ;checks if Set As Default button is enabled
If $result Then
        ;if Set As Default is enabled we can enable this device
    ControlClick("Sound",  "", "Button2") ;Click Set As Default
    ControlClick("Sound", "", "Button4") ;Click OK
    Traytip("Audio Out", "Sennheiser RS180", 5, 1)
    Sleep(5000)
    Exit
EndIf

Thanks in advance!

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.