Welcome Guest.   Make a donation to an author on the site August 27, 2014, 08:09:29 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Check out and download the GOE 2007 Freeware Challenge productivity tools.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: Prev 1 [2]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: DONE: A shortcut/hotkey to switch between audio devices?  (Read 28671 times)
moerl
Charter Member
***
Posts: 404


View Profile Give some DonationCredits to this forum member
« Reply #25 on: April 12, 2006, 04:48:13 PM »

Hmmmm.. ok. I downloaded the script file, double clicked it while Realtek Audio is active, and while I do see the Audio properties popup and disappear right away, nothing changes. The device is not switched.

This is the script I used:

[copy or print]
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}
Logged
moerl
Charter Member
***
Posts: 404


View Profile Give some DonationCredits to this forum member
« Reply #26 on: April 12, 2006, 04:52:43 PM »

I just found out something else as well that's interesting. If I have the system set to use the Sennheiser headset and THEN execute the AHK script, it works EXACTLY as desired, switching the used sound device from the headset to the system's soundcard, Realtek Audio. However, if Realtek is selected first and the script is executed, no change occurs. In other words, the script works exactly as it should, but only one way...
Logged
Carol Haynes
Waffles for England (patent pending)
Global Moderator
*****
Posts: 7,952



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #27 on: April 12, 2006, 06:08:35 PM »

Looks like the ahk_class parameter is set incorrectly ... I'll see if I can work out what it should be tomorrow.
Logged

moerl
Charter Member
***
Posts: 404


View Profile Give some DonationCredits to this forum member
« Reply #28 on: April 12, 2006, 06:57:05 PM »

Thanks smiley. I wish I could do it myself but I don't even have a damn clue how that super simple script I have now works... so... thanks.
Logged
jgpaiva
Global Moderator
*****
Posts: 4,710



Artificial Idiocy

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #29 on: April 12, 2006, 07:01:20 PM »

The problem is that it is never noticing that the string " RealTek AC97 Audio" is in the window.
Try changing that line to "IfWinActive,ahk_class #32770,Realtek". I don't think that'll solve it, but it's worth trying.
Still, if that doesn't work, you can always make 2 different scripts, as Carol mentioned. Or, if you use it very often, make one script, with hotkeys.
Logged

Carol Haynes
Waffles for England (patent pending)
Global Moderator
*****
Posts: 7,952



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #30 on: April 12, 2006, 07:05:01 PM »

This version seems to work for me (see attached zip)

[copy or print]
SetTitleMatchMode, Slow

Run, RunDll32.exe shell32.dll`,Control_RunDLL mmsys.cpl`,`,2
WinWait, Sounds and Audio Devices Properties

 IfWinActive, Sounds and Audio Devices Properties, RealTek AC97 Audio
     send, {alt down}d{alt up}s{enter}
 else
     send, {alt down}d{alt up}r{enter}

* toggle.zip (0.3 KB - downloaded 399 times.)
« Last Edit: April 12, 2006, 07:07:39 PM by Carol Haynes » Logged

moerl
Charter Member
***
Posts: 404


View Profile Give some DonationCredits to this forum member
« Reply #31 on: April 12, 2006, 07:37:21 PM »

This version seems to work for me (see attached zip)

[copy or print]
SetTitleMatchMode, Slow

Run, RunDll32.exe shell32.dll`,Control_RunDLL mmsys.cpl`,`,2
WinWait, Sounds and Audio Devices Properties

 IfWinActive, Sounds and Audio Devices Properties, RealTek AC97 Audio
     send, {alt down}d{alt up}s{enter}
 else
     send, {alt down}d{alt up}r{enter}
It behaves just the same way as I described earlier. When I have the Sennheiser headset set, this script can switch it to Realtek Audio. However, if Realtek Audio selected, it is not able to switch it to the Sennheiser headset. I wonder why! I mean.. it does work perfectly in one direction... just not in the other :/
Logged
moerl
Charter Member
***
Posts: 404


View Profile Give some DonationCredits to this forum member
« Reply #32 on: April 12, 2006, 07:41:23 PM »

The problem is that it is never noticing that the string " RealTek AC97 Audio" is in the window.
Try changing that line to "IfWinActive,ahk_class #32770,Realtek". I don't think that'll solve it, but it's worth trying.
Still, if that doesn't work, you can always make 2 different scripts, as Carol mentioned. Or, if you use it very often, make one script, with hotkeys.
Oh my... YOU DID IT! Your suggestion fixed the problem! It works now, in both directions cheesy:D:D. Brilliant! Thank you very much. Thanks to everybody else trying to help as well. Just awesome. Wow Wink

AHK is sweet. Now only to figure out how the hell to use it, and I'll be set!

While I'm at it.. how do I set a hotkey for scripts? And does AutoHotKey itself have its own GUI.. if so, how can it be accessed? I do have an entry for AHK on the start menu, but when I start AutoHotKey it starts with the default INI file and nothing really happens from what I could tell. It just opens the ini file in text-editing mode in notepad.
Logged
moerl
Charter Member
***
Posts: 404


View Profile Give some DonationCredits to this forum member
« Reply #33 on: April 12, 2006, 07:45:56 PM »

Oops nevermind.. when I start it from the start menu, I get the AHK icon in the system tray and can access it from there. Not that the window that opens makes any sense to me whatsoever, but at least it's working. Of course I have to read the documentation if I want to understand it, and I can't wait to get to that, but I have no time to do that now.

Again, thanks so much to all of you for trying to help.
Logged
Carol Haynes
Waffles for England (patent pending)
Global Moderator
*****
Posts: 7,952



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #34 on: April 12, 2006, 07:49:11 PM »

If you create a shortcut for the script (rather than running it directly) and then right click on the shortcut you can set a global hotkey for that shortcut. Then you should be able to toggle with a single hotkey press to your hearts content Wink
Logged

jgpaiva
Global Moderator
*****
Posts: 4,710



Artificial Idiocy

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #35 on: April 12, 2006, 07:54:56 PM »

Oh my... YOU DID IT! Your suggestion fixed the problem! It works now, in both directions cheesy:D:D. Brilliant! Thank you very much. Thanks to everybody else trying to help as well. Just awesome. Wow Wink
Great, that means that the problem was related with that string, mos probably, it was looking for " Realtek" instead of "Realtek" (notice the preceding space). Anyways, good to know it's working.

AHK is sweet. Now only to figure out how the hell to use it, and I'll be set!
It took me one week to start making great stuff, and one month to know almost everything there is about it. Don't worry, it's really fast to learn.

While I'm at it.. how do I set a hotkey for scripts? And does AutoHotKey itself have its own GUI.. if so, how can it be accessed? I do have an entry for AHK on the start menu, but when I start AutoHotKey it starts with the default INI file and nothing really happens from what I could tell. It just opens the ini file in text-editing mode in notepad.
AHK is a scripting language, that means there is no gui, because it's not a "real" program. I'd say the best place for you to start is the help file, which is an exelent resource, and has tuturials on how to do the basic stuff.
The help file is so good, that it's a constant reference, even for everyone that knows how to program in AHK. You should have a good look at it, it'll take out all your doubts Wink
Logged

lanux128
Global Moderator
*****
Posts: 6,088



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #36 on: April 12, 2006, 08:39:40 PM »

i'm glad to see that things picked up while i was not around. thumbs up amazingly, it was solved in just 4hrs 45mins... Wink
i think now is a good time to move this topic to "Finished Programs" on Coding Snacks.

...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 :/

microsoft, in their infinite wisdom, have disabled the right-click menu in the "New Shortcut" dialog but you can press Control-V to paste the command. since you have already have a working script, this is just some additional info for the future...
Logged

moerl
Charter Member
***
Posts: 404


View Profile Give some DonationCredits to this forum member
« Reply #37 on: April 12, 2006, 08:45:54 PM »

i'm glad to see that things picked up while i was not around. thumbs up amazingly, it was solved in just 4hrs 45mins... Wink
i think now is a good time to move this topic to "Finished Programs" on Coding Snacks.

...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 :/

microsoft, in their infinite wisdom, have disabled the right-click menu in the "New Shortcut" dialog but you can press Control-V to paste the command. since you have already have a working script, this is just some additional info for the future...
Nono.. I didn't mean that. I know the paste command, of course, and never use the mouse. I meant that the dialog that shows up does not accepts commands. It wants a file path for the file you want to create the shortcut for. I did try pasting the command and clicking next and it just told me "Can't find file "Run"" or something like that, when "Run" was the first word of the command...
But yeah, the problem is solved. This is just a side discussion smiley
Logged
lanux128
Global Moderator
*****
Posts: 6,088



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #38 on: April 12, 2006, 08:58:31 PM »

a'ah, i see... ok then use the full path to runDll32.exe, which should be in the system32 folder...

[copy or print]
C:\Windows\System32\RunDll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,2
- or -

[copy or print]
%windir%\System32\RunDll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,2

hmm.. maybe, i'll post a new topic containing all these handy short-cuts. undecided
now, if only i could find them...
Logged

brotherS
Master of Good Ideas
Honorary Member
**
Posts: 2,105


To make a difference, be different.

View Profile Give some DonationCredits to this forum member
« Reply #39 on: April 13, 2006, 02:08:09 AM »

It works now, in both directions cheesy
Then please post the full code here for others to easily see it. Just click on the "#" above.
Logged

Thank you.
wr975
Charter Member
***
Posts: 369



View Profile Give some DonationCredits to this forum member
« Reply #40 on: April 13, 2006, 02:31:05 AM »

Quote
Then please post the full code here for others to easily see it

Here's the working AHK script. Four people wrote on it, thanks to everyone involved!  Thmbsup

[copy or print]

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}
« Last Edit: April 13, 2006, 02:32:41 AM by wr975 » Logged
DesertEagle
Charter Honorary Member
***
Posts: 16

View Profile WWW Give some DonationCredits to this forum member
« Reply #41 on: June 22, 2006, 07:35:47 PM »

Take a look at Audio Sliders (http://www.codesector.com/mixer.asp), it can change default playback and recording devices with single click on its tray icon.


* hotkeys.gif (8.15 KB, 351x319 - viewed 439 times.)
Logged
zYx
Participant
*
Posts: 2

View Profile Give some DonationCredits to this forum member
« Reply #42 on: November 30, 2008, 03:34:07 PM »

Hi,

how do I do it in windows vista?

Cheers
« Last Edit: November 30, 2008, 03:35:56 PM by zYx » Logged
Ryan_S
Participant
*
Posts: 6


View Profile Give some DonationCredits to this forum member
« Reply #43 on: January 02, 2009, 09:19:54 PM »

I thought I'd add a script here for changing the device in Vista. I needed this for my XPS1530 for switching between the HDMI output and the speakers.

I had to write it in AutoIT because AutoHotKey doesn't support working with the SysListView directly, and I'm not a huge fan of sending keystrokes. I also couldn't find the registry keys in Vista. Seems MS has moved those.

Formatted for AutoIt with the GeSHI Syntax Highlighter [copy or print]
  1. Run("c:\windows\system32\control.exe mmsys.cpl")
  2.  
  3. WinWaitActive("Sound")
  4.  
  5. ControlListView("Sound", "", "SysListView321", "Select", 0) ;Select the first device in the list
  6. $result = ControlCommand("Sound", "", "Button2", "IsEnabled", "") ;checks if Set As Default button is enabled
  7. If $result Then
  8.        ;if Set As Default is enabled we can enable this device
  9. ControlClick("Sound",  "", "Button2") ;Click Set As Default
  10. ControlClick("Sound", "", "Button4") ;Click OK
  11. Traytip("Audio Out", "Speakers / Headphones selected", 5, 1)
  12. Sleep(5000)
  13.  
  14. ControlListView("Sound", "", "SysListView321", "Select", 1) ;select the second device in the list
  15. $result = ControlCommand("Sound", "", "Button2", "IsEnabled", "") ;checks if Set As Default button is enabled
  16. If $result Then
  17.        ;if Set As Default is enabled we can enable this device
  18. ControlClick("Sound",  "", "Button2") ;Click Set As Default
  19. ControlClick("Sound", "", "Button4") ;Click OK
  20. Traytip("Audio Out", "HDMI selected", 5, 1)
  21. Sleep(5000)
« Last Edit: January 02, 2009, 09:30:00 PM by Ryan_S » Logged
Pages: Prev 1 [2]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.126s | Server load: 0.02 ]