Page 1 of 1

Shortcuts to Change Speaker Modes

Posted: Thu Jan 29, 2009 8:08 pm
by Sovereign
I have a roommate (I'm in college) and there's an unspoken rule that in general, when the other is there you use headphones. That's fine, but since I have an X-Fi everything sounds funny if it's set on "2.1 Speakers" when I'm listening through headphones (no, the software cannot detect whether I am using headphones or speakers). Thus, I have to open the control panel (for the X-Fi), change the setting, then close it again. It's annoying. Some Googling produced this forum post which I modified to suit an X-Fi (even the simple things, like "Audio Console," break the VBS, it needs to be "Audio Control Panel").

This is not my code (see above source); I just made it X-Fi compliant.

Code: Select all

' ================== 1st script ====================

'----- Start Of "Headpones.vbs" ----- (Save as Headphones.vbs) ---------------------

Option Explicit

Dim WshShell
Set WshShell = CreateObject("WScript.Shell" )

' Start up the Audio Console
WshShell.CurrentDirectory = "C:\Program Files (x86)\Creative\AudioCS\"
WshShell.Run "CTAudCS.exe"
' lets open the console
While WshShell.AppActivate("Audio Control Panel") = FALSE
wscript.sleep 200
WshShell.AppActivate "Audio Control Panel"
Wend
'
' send some keystrokes to get the speaker settings box activated
'
'
WshShell.SendKeys("{TAB}{TAB}{TAB}{RIGHT}{TAB}{TAB}" )

'
' set the speaker selection to Headphones
'
WshShell.SendKeys("{h}" )
'
' exit Audio Control Panel -panel
'
WshShell.SendKeys("{TAB}{TAB}{ENTER}" )

WScript.Quit(0)

'----- End Of "Headphones.vbs" -------------------------------------------------------------

Code: Select all

' ================== 2nd script ====================


'----- Start Of "2.1.vbs" ----- (Save as 2.1.vbs) -------------------------------------------

Option Explicit

Dim WshShell
Set WshShell = CreateObject("WScript.Shell" )

' Start up the Audio Console
WshShell.CurrentDirectory = "C:\Program Files (x86)\Creative\AudioCS\"
WshShell.Run "CTAudCS.exe"
' lets open the console
While WshShell.AppActivate("Audio Control Panel") = FALSE
wscript.sleep 200
WshShell.AppActivate "Audio Control Panel"
Wend
'
' send some keystrokes to get the speaker settings box activated
'
'
WshShell.SendKeys("{TAB}{TAB}{TAB}{RIGHT}{TAB}{TAB}" )

'
' set the speaker selection to 2.1
'
WshShell.SendKeys("{2}" )
'
' exit Audio Control Panel -panel
'
WshShell.SendKeys("{TAB}{TAB}{ENTER}" )

WScript.Quit(0)

'----- End Of "Headphones to 2.1.vbs" -----
Note that if you change "SendKeys" you can change what mode you're activating.

H - Headphones
2 - 2.1 Speakers
4 - 4.1 Speakers
5 - 5.1 Speakers
7 - 7.1 Speakers

Make sure the Control Panel is closed before you use these. You do not need to "Run as Administrator" on Vista; they just work. Also note that the program path assumes Vista x64 (which has a "Program Files (x86)" folder that does not exist on 32-bit Vista; it's just Program Files.)