topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Sunday October 6, 2024, 12:27 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: DONE: A shortcut/hotkey to switch between audio devices?  (Read 57220 times)

moerl

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 404
    • View Profile
    • Donate to Member
How could I make switching between the Realtek device and the Sennheiser USB headset really fast? :)

Normally, to do this, I have to do the following:

1. Click Start, Control Panel.
2. Open Sounds & Audio Devices
3. Select "Audio" tab
4. From "Sound Playback" devices choose the wanted device from the dropdown list
5. Click Apply, then OK.
6. Close control panel

In short, it's a huge pain in the ass and this really is something that I want to be able to do on the fly. Any ideas?

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 8,068
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #1 on: April 11, 2006, 03:43 AM »
A Macro would do it quickly

moerl

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 404
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #2 on: April 12, 2006, 01:09 AM »
What kind of macro?

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #3 on: April 12, 2006, 01:36 AM »
What kind of macro?

e.g. this command below opens the Audio tab in your Multimedia Devices applet.
RunDll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,2

maybe someone here can figure out how to change the items in the combo-box via AHK...
MMSYS-CPL1.pngDONE: A shortcut/hotkey to switch between audio devices?



moerl

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 404
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #4 on: April 12, 2006, 01:45 AM »
That's no bad start. No bad start at all. Thanks! Before we figure out the real deal, how could I turn the command you came up with into a shortcut that, when clicked, for example from the quicklaunch bar, would get me to that window?

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #5 on: April 12, 2006, 02:02 AM »
i believe that once this topic is picked by one of our AHK pros, you'll have a decent app in your hands. ;)

in the meantime, you can create a shortcut as you normally do... right-click on desktop, choose New>Shortcut. then paste the command, type an appropriate name then drag the newly-created shortcut to the quicklaunch bar.

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #6 on: April 12, 2006, 03:52 AM »
Great work lanux!
This can be easily done, if the window is opened as "hidden". But i don't know how to see which item is selected in that combobox, so, you'd always have to tell the script which device to activate, every time you ran it, and you'd have to pre-configure it to tell it how many items the combobx has. Nevertheless, it can be done.
But i think skrommel knows how to get the names in the combobox, and will come up with a great solution ;)

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 8,068
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #7 on: April 12, 2006, 04:56 AM »

e.g. this command below opens the Audio tab in your Multimedia Devices applet.
RunDll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,2


Great start ...

Once the window is open you can use ALT D to make sure the device field is highlighted.

If the device names start with different letters just press the first letter to select the device and press return to close the window.

An AHK script to do this would be:

Run, RunDll32.exe shell32.dll`,Control_RunDLL mmsys.cpl`,`,2
Sleep, 1000
send, {alt down}d{alt up}m{enter}

where m (in the last line) is the first letter of your device name.

If you make two scripts, one for each device you can just double click the correct device when you need to swap.

You may need to fiddle with the sleep delay too on your system depending on how quickly the window opens.
« Last Edit: April 12, 2006, 04:58 AM by Carol Haynes »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #8 on: April 12, 2006, 05:04 AM »
Common development.. Nice.

my 0,02$:
Run, RunDll32.exe shell32.dll`,Control_RunDLL mmsys.cpl`,`,2
WinWait,ahk_class #32770
send, {alt down}d{alt up}m{enter}
This code should work a little better, since it waits for the window to appear.

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 8,068
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #9 on: April 12, 2006, 06:09 AM »
Thanks - trouble with AHK is that there are just too many damn options for everything!

brotherS

  • Master of Good Ideas
  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 2,261
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #10 on: April 12, 2006, 06:18 AM »
If you make two scripts, one for each device you can just double click the correct device when you need to swap.
-Carol Haynes (April 12, 2006, 04:56 AM)
Or you could just create one AHK script that's writing some kind of indicator to an .ini file and every time the script is executed it changes the device to the one not being selected the last time.

AHK = great :)

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 8,068
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #11 on: April 12, 2006, 06:24 AM »
Actually it should be trivial to organise this to have a hotkey to do the swapping ... no time at the mo (I'm sure someone can write it in 2 secs but I need to scour the helpfiles) maybe later if no one has done it.

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #12 on: April 12, 2006, 06:32 AM »
Or you could just create one AHK script that's writing some kind of indicator to an .ini file and every time the script is executed it changes the device to the one not being selected the last time.
Yes, but that would force Moerl to switch the options only though this script, or it wouldn't do things right.

@Moer: to make a decent script, i need to know the name of the options in that box, and how many there are.

brotherS

  • Master of Good Ideas
  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 2,261
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #13 on: April 12, 2006, 06:59 AM »
Or you could just create one AHK script that's writing some kind of indicator to an .ini file and every time the script is executed it changes the device to the one not being selected the last time.
Yes, but that would force Moerl to switch the options only though this script, or it wouldn't do things right.
True, but since he was referring to doing it manually as a "pain in the ass", I hardly doubt he will ever do it again without a good working script! :D

wr975

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 369
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #14 on: April 12, 2006, 07:01 AM »

I think the script can act as toggle without ini. What do you think of this? (Untested).

SetTitleMatchMode, Slow

Run, RunDll32.exe shell32.dll`,Control_RunDLL mmsys.cpl`,`,2
WinWait,ahk_class #32770

IfWinActive, ahk_class #32770, RealTek AC97 Audio
     send, {alt down}d{alt up}s{enter}
else
     send, {alt down}d{alt up}r{enter}

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #15 on: April 12, 2006, 07:05 AM »
Good point, wr975!
Now, I only need Moerl's audio devices' names!

moerl

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 404
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #16 on: April 12, 2006, 03:50 PM »
Damn. Some sweet work has been done in here. I've never used AHK. Each time I looked at it it was too much to digest, too much to handle, so I let it be :).

jgpaiva: where do I get them? I'm not sure what you mean by the names.

brotherS

  • Master of Good Ideas
  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 2,261
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #17 on: April 12, 2006, 04:00 PM »
Damn. Some sweet work has been done in here. I've never used AHK. Each time I looked at it it was too much to digest, too much to handle, so I let it be :).
Then it's time to visit the quick-start tutorial: http://www.autohotke...om/docs/Tutorial.htm

DC wasn't built in one night, and AHK is a journey - don't hope to start it some day in the far future, just jump in and enjoy the ride!

I started with very basic stuff and am constantly learning new stuff, whenever I tackle a new challenge.

moerl

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 404
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #18 on: April 12, 2006, 04:11 PM »
I'll get to it. I have so many things around me that need to be done :(. I hate when that's the case :)

moerl

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 404
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #19 on: April 12, 2006, 04:16 PM »

I think the script can act as toggle without ini. What do you think of this? (Untested).

SetTitleMatchMode, Slow

Run, RunDll32.exe shell32.dll`,Control_RunDLL mmsys.cpl`,`,2
WinWait,ahk_class #32770

IfWinActive, ahk_class #32770, RealTek AC97 Audio
     send, {alt down}d{alt up}s{enter}
else
     send, {alt down}d{alt up}r{enter}
Is this an AHK script or a "regular" script?

Until I figure that out, I'll try jgpaiva's solution here:
Common development.. Nice.

my 0,02$:
Run, RunDll32.exe shell32.dll`,Control_RunDLL mmsys.cpl`,`,2
WinWait,ahk_class #32770
send, {alt down}d{alt up}m{enter}
This code should work a little better, since it waits for the window to appear.

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 8,068
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #20 on: April 12, 2006, 04:18 PM »
where do I get them? I'm not sure what you mean by the names.

When you open the normal window the names are the ones you select in the drop down menu. Actually they are listed in your original post LOL

The first letters are S (Senheiser) and R (Realtek) - the script above already has the right letters.

All you need to do is download and install autohotkey (http://www.autohotke...utoHotkeyInstall.exe) save the script above via a text editor with .ahk as it's extension and then doubleclick the script file to toggle your sound card.

(I have attached the AHK script to this post in a zip file)
« Last Edit: April 12, 2006, 04:20 PM by Carol Haynes »

moerl

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 404
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #21 on: April 12, 2006, 04:24 PM »
i believe that once this topic is picked by one of our AHK pros, you'll have a decent app in your hands. ;)

in the meantime, you can create a shortcut as you normally do... right-click on desktop, choose New>Shortcut. then paste the command, type an appropriate name then drag the newly-created shortcut to the quicklaunch bar.
I thought it was that simple too.. but when I right-click the desktop and choose NEW SHORTCUT the window that appears asks me for the file's location to which I want to create a shortcut. I can't just drop the code in that line :/

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 8,068
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #22 on: April 12, 2006, 04:32 PM »
Another way to create a shortcut is to right click on the target file and choose Send to ... >Desktop (Create Shortcut)

moerl

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 404
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #23 on: April 12, 2006, 04:39 PM »
where do I get them? I'm not sure what you mean by the names.

When you open the normal window the names are the ones you select in the drop down menu. Actually they are listed in your original post LOL

The first letters are S (Senheiser) and R (Realtek) - the script above already has the right letters.

All you need to do is download and install autohotkey (http://www.autohotke...utoHotkeyInstall.exe) save the script above via a text editor with .ahk as it's extension and then doubleclick the script file to toggle your sound card.

(I have attached the AHK script to this post in a zip file)
-Carol Haynes (April 12, 2006, 04:18 PM)
Exactly! That's why I was confused by jgpaiva's request, because I thought he meant something else still. I intentially took the screenshot with the whole dropdown list showing for the exact reason to show you all the names of the devices. Thanks for clearing that up :). While reading your post, I realized I wouldn't know which script to pick from above, so I'm doubly thankful that you attached it as a ZIP. Thanks :)

Another way to create a shortcut is to right click on the target file and choose Send to ... >Desktop (Create Shortcut)
-Carol Haynes (April 12, 2006, 04:32 PM)
Right.. what file would that be? A new text file with the information pasted in it? Would it remain a text file or would I have to change the extension to something else? I'll check out AHK now so this is not too important.
« Last Edit: April 12, 2006, 04:50 PM by moerl »

moerl

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 404
    • View Profile
    • Donate to Member
Re: A shortcut/hotkey to switch between audio devices?
« Reply #24 on: April 12, 2006, 04:40 PM »
I saw SmartGUI Creator on the AHK download page. That sounds intriguing :)