ElXando Posted June 14, 2011 Share Posted June 14, 2011 Hi there, I regularly swap audio devices on my PC due to Windows incapability to playback through 2 at once - after some googling I found an AutoIt script someone had written to do exactly that! I downloaded and installed AutoIt, pasted the script into the editor, saved it and compiled it as an .exe. I then use my keyboard software to assign one of my media buttons to open the program. One small problem - after the Sound window it opened, it doesn't become active, so it sits there until I click on it. Here's the script: ;-----Configuration----- ;The title of the sound config window. Dim $ConfigWindowTitle = "Sound" ;-----End of configuration---- Dim $ItemNumber = 4 ; The first itme in the audio list If FileExists ("a") Then; Use the existence of a file to know if we should toggle FileDelete("a") $ItemNumber = 2 ; The audio playback device you want to toggle to Else FileOpen("a", 1) FileClose("a") EndIf Run("control mmsys.cpl") ;Run the sound control applet and hide it. WinWaitActive($ConfigWindowTitle) ;Wait for it to be active before sending keystrokes. Send("{TAB}{TAB}{TAB}{TAB}") ;Put the focus on the list For $i = 1 to $ItemNumber Step 1 Send("{DOWN}") Next Send("!s") ;Press Alt + S to set the selected device as the default. WinClose($ConfigWindowTitle) I did some googling to see if I could solve this, and tried adding "WinGetTitle("Sound")" just before the WinWaitActive bit, but to no avail. Also, I was wondering if I could make it only change the default device, not the default device and default communications device. Thanks! Link to comment Share on other sites More sharing options...
disposable Posted June 14, 2011 Share Posted June 14, 2011 Perhaps you should try the direct approach and do the changes to the registry instead of opening the control panel applet. try looking for \\HK... Software\Microsoft\Multimedia\Sound Mapper Autoit has a complete set of registry editing functions built in. Link to comment Share on other sites More sharing options...
ElXando Posted June 16, 2011 Author Share Posted June 16, 2011 Perhaps you should try the direct approach and do the changes to the registry instead of opening the control panel applet.try looking for \\HK... Software\Microsoft\Multimedia\Sound MapperAutoit has a complete set of registry editing functions built in.Errr... I'm not sure how I'd go about that, I'm not very familiar with AutoIt It'd be far easier to just modify this script to just make Sound the active window I think, just a bit stumped :/ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now