|
moerl
|
 |
« 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
|
 |
« 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
|
 |
« 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
|
 |
« Reply #28 on: April 12, 2006, 06:57:05 PM » |
|
Thanks  . 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
|
 |
« 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
|
 |
« 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}
|
|
|
« Last Edit: April 12, 2006, 07:07:39 PM by Carol Haynes »
|
Logged
|
|
|
|
|
moerl
|
 |
« 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
|
 |
« 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  :D:D. Brilliant! Thank you very much. Thanks to everybody else trying to help as well. Just awesome. Wow  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
|
 |
« 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
|
 |
« 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 
|
|
|
|
|
Logged
|
|
|
|
|
jgpaiva
|
 |
« 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  :D:D. Brilliant! Thank you very much. Thanks to everybody else trying to help as well. Just awesome. Wow  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 
|
|
|
|
|
Logged
|
|
|
|
|
lanux128
|
 |
« Reply #36 on: April 12, 2006, 08:39:40 PM » |
|
i'm glad to see that things picked up while i was not around.  amazingly, it was solved in just 4hrs 45mins...  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
|
 |
« Reply #37 on: April 12, 2006, 08:45:54 PM » |
|
i'm glad to see that things picked up while i was not around.  amazingly, it was solved in just 4hrs 45mins...  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 
|
|
|
|
|
Logged
|
|
|
|
|
lanux128
|
 |
« 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. now, if only i could find them...
|
|
|
|
|
Logged
|
|
|
|
brotherS
Master of Good Ideas
Honorary Member

Posts: 2,105
To make a difference, be different.
|
 |
« Reply #39 on: April 13, 2006, 02:08:09 AM » |
|
It works now, in both directions  Then please post the full code here for others to easily see it. Just click on the "#" above.
|
|
|
|
|
Logged
|
Thank you.
|
|
|
|
wr975
|
 |
« Reply #40 on: April 13, 2006, 02:31:05 AM » |
|
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!  [ 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
|
|
|
|
|
|
|
zYx
|
 |
« 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
|
 |
« 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] Run("c:\windows\system32\control.exe mmsys.cpl") ControlListView("Sound", "", "SysListView321", "Select", 0) ;Select the first device in the list $result = ControlCommand("Sound", "", "Button2", "IsEnabled", "") ;checks if Set As Default button is enabled ;if Set As Default is enabled we can enable this device Traytip("Audio Out", "Speakers / Headphones selected", 5, 1) ControlListView("Sound", "", "SysListView321", "Select", 1) ;select the second device in the list $result = ControlCommand("Sound", "", "Button2", "IsEnabled", "") ;checks if Set As Default button is enabled ;if Set As Default is enabled we can enable this device Traytip("Audio Out", "HDMI selected", 5, 1)
|
|
|
|
« Last Edit: January 02, 2009, 09:30:00 PM by Ryan_S »
|
Logged
|
|
|
|
|