Jump to content

Changing audio adapter


gertsolo
 Share

Recommended Posts

Hey there,

I'm new to AutoIt so be gentle.

Would it be possible to change the audio adapter from one to another with AutoIt.

I'll explain myself. I have an onboard audio adapter and a soundblaster card. From time to time I want to change the one windows should use. This is normally done through control panel -> sounds and audio settings -Audio tab -> and then device for audio where you can choose the adapter.

thx in advance

GertSolo

The more you learn, the less you know.

Link to comment
Share on other sites

Since i'm sick of looking at php code I created the ULTIMATE AUDIO SWITCHER! Ok it's not that ultimate.

This will load the audio control panel, determine the current device, and if there is more than one it will cycle to the next audio device.

If there are only 2 devices to choose from it will toggle.

Also, it will display a traytip with the name of the device being switched to.

#Include <GuiCombo.au3>
#Include <GuiTab.au3>
$title = "Sounds and Audio Devices Properties"

Run('"C:\WINDOWS\system32\rundll32.exe" C:\WINDOWS\system32\shell32.dll,Control_RunDLL "C:\WINDOWS\system32\MMSYS.CPL",@0')
WinWaitActive($title)
$tabHwnd = ControlGetHandle ( $title, "", "[CLASS:SysTabControl32; INSTANCE:1]" )
If @ERROR THEN MsgBox(0,"","ERROR")

_GUICtrlTabSetCurFocus ( $tabHwnd, 2)
_GUICtrlTabSetCurSel ( $tabHwnd, 2)

$comboHWND = ControlGetHandle ($title, "", "[CLASS:ComboBox; INSTANCE:1]" )
If @ERROR THEN MsgBox(0,"","ERROR")

$itemCount = _GUICtrlComboGetCount ($comboHWND)
$currentIndex = _GUICtrlComboGetCurSel ($comboHWND)

If $currentIndex < $itemCount - 1 Then
    _GUICtrlComboSetCurSel ( $comboHWND, $currentIndex + 1 )
    $newIndex = $currentIndex + 1
Else
    _GUICtrlComboSetCurSel ( $comboHWND, 0)
    $newIndex = 0
EndIf

$result = ""
_GUICtrlComboGetLBText ( $comboHWND, $newIndex, $result)

ControlClick($title, "", "Button11")
TrayTip ( "Audio device switched to:", $result, 5)
Sleep(5000)
Edited by weaponx
Link to comment
Share on other sites

Hey Weaponx,

one question though, I tried it today on a English XP and it worked fine.

Here at home I'm using a dutch version of XP.

Should I change something in the script to get it running again?

Now it stops after opening the audio control dialog.

BTW on this PC I got 3 audio adapter.

Edit: never mind I got it, just had to change the $title value, my bad, very nooby...

rgds!

Edited by gertsolo

The more you learn, the less you know.

Link to comment
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
 Share

  • Recently Browsing   0 members

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