 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
TheIceMan Guest
|
Posted: Mon Feb 21, 2005 6:21 am Post subject: Changing default audio device |
|
|
I'm looking for a way to automate the procedure of switching from one audio device to another. Typically, this involves going to the control panel --> sound and audio devices --> audio --> default device --> etc etc
Is there any way to create a script that will automatically change the device, run a particular program (for example, tv tuner software that is incompatible with my USB audio out), then change the audio device back to what it was originally...?
Any suggestions or help would be very much appreciated! |
|
| Back to top |
|
 |
procyon
Joined: 10 Feb 2005 Posts: 14 Location: Tallinn, Estonia
|
Posted: Mon Feb 21, 2005 8:36 am Post subject: |
|
|
I actually use AHK for switching between my two soundcards.
My script is for WinXP, so if you have another OS, you may need to change window titles etc.
| Code: | Run, mmsys.cpl
Sleep, 100
WinWait, Sounds and Audio Devices Properties
IfWinNotActive, Sounds and Audio Devices Properties WinActivate, Sounds and Audio Devices Properties
WinWaitActive, Sounds and Audio Devices Properties
Send, ^{Tab}
Sleep, 100
Send, ^{Tab}
Sleep, 100
WinWait, Sounds and Audio Devices Properties
IfWinNotActive, Sounds and Audio Devices Properties WinActivate, Sounds and Audio Devices Properties
WinWaitActive, Sounds and Audio Devices Properties
Send, {Down}
Sleep, 50
Send, !A
Sleep, 100
Send, {Enter} |
As a sidenote - this script switches between two audio devices and I don't have a clue which device it would select if you have more. |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Mon Feb 21, 2005 8:54 am Post subject: |
|
|
| Quote: | SoundSet
--------------------------------------------------------------------------------
Changes various settings of a sound device (master mute, master volume, etc.)
SoundSet, NewSetting [, ComponentType, ControlType, DeviceNumber]
If this parameter is omitted, it defaults to 1 (the first sound device), which is usually the system's default device for recording and playback. Specify a number higher than 1 to operate upon a different sound device. |
Might be of interest.
 |
|
| Back to top |
|
 |
procyon
Joined: 10 Feb 2005 Posts: 14 Location: Tallinn, Estonia
|
Posted: Mon Feb 21, 2005 10:36 am Post subject: |
|
|
| Quote: | SoundSet
--------------------------------------------------------------------------------
Changes various settings of a sound device (master mute, master volume, etc.)
SoundSet, NewSetting [, ComponentType, ControlType, DeviceNumber]
If this parameter is omitted, it defaults to 1 (the first sound device), which is usually the system's default device for recording and playback. Specify a number higher than 1 to operate upon a different sound device.
|
SoundSet only changes volume etc. of a selected device, but it does not change which device is active. |
|
| Back to top |
|
 |
adlib Guest
|
Posted: Tue Mar 01, 2005 6:58 pm Post subject: |
|
|
Great script procyon! Thx for sharing.
Sidenote tho, the !A-command is irrelevant as the simple enter-press does apply aswell as close the window. Makes it all slightly faster
Also, why use the sleep-command when you will be waiting for the window to emerge anyway? |
|
| Back to top |
|
 |
Bigrob55
Joined: 24 Sep 2007 Posts: 10
|
Posted: Sat Nov 24, 2007 12:28 pm Post subject: |
|
|
Awsome Script!!
I had always wanted to do this, but i had no idea about this part
Thanks Alot for posting this.
I changed it a Lil bit on mine
| Code: | Send, ^{Tab 2}
Sleep, 100 |
High Five!! _________________ Bigrob
L337 Speak - A Ventrilo Client Side program |
|
| Back to top |
|
 |
XavierGr
Joined: 15 Jul 2006 Posts: 42
|
Posted: Wed May 14, 2008 1:19 am Post subject: |
|
|
The most easy and non-obstructing way to do this is via RegRead and ReadWrite.
Windows stores the default playback device under the "HKEY_CURRENT_USER\ Software\Microsoft\Multimedia\Sound Mapper\Playback" key.
Doing something like this will switch between my onboard realtek and creative audigy se sounds cards that I have on my rig:
| Code: |
; Toggle Sound Devices
!+s::
RegRead, Device, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback
if(Device = "Realtek HD Audio output")
{
RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback, Sound Blaster Audigy
Device := "Audigy"
}
else
{
RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback, Realtek HD Audio output
Device := "Realtek"
}
ToolTip, % "Sound Device: " Device
SetTimer, ResetToolTip, 1000
return
; Clear the ToolTip
ReSetToolTip:
ToolTip
SetTimer, ReSetToolTip, Off
return
|
Change the "if(Device = ...)" line with your sound card names.
Unfortunately I haven't found a way to make windows update all the programs running with the new default sound card device. That way even if I change the default by hand I have to restart my processes to update them with the new sound device. _________________ One hotkey to rule them all! |
|
| Back to top |
|
 |
Rhys
Joined: 17 Apr 2007 Posts: 707 Location: Florida
|
Posted: Wed May 14, 2008 3:13 am Post subject: |
|
|
Thanks, this will help me when I get around to making a script that will detect when I plug my HDMI cable into my laptop and change the default playback device for me! Too bad I'm so lazy or I'd have done it by now  _________________ [Join IRC!]
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|