Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Help a newb with this script
New Posts  All Forums:Forum Nav:

Help a newb with this script

post #1 of 4
Thread Starter 
Hi,

I'm running auto hotkey so I can bind a key to switch between my headphones and speakers. My headphones are in my sound card (with the heapdhone amp) and my speakers are in my mobo line out.

Here's the script.

F1::
Run, mmsys.cpl
WinWait,Sound
ControlSend,SysListView321,{Down}
ControlClick,&Set Default
ControlClick,OK
return

F2::
Run, mmsys.cpl
WinWait,Sound
ControlSend,SysListView321,{Down 3}
ControlClick,&Set Default
ControlClick,OK
return


It works most of the time, but sometimes it doesn't work. Anyway to make this better?
    
CPUMotherboardGraphicsRAM
Intel i5-4670K MSI Z87-G41 ASUS GTX 660 Corsair 8GB 
Hard DriveOptical DriveOSMonitor
9TB  None Windows 7 Dell U2713HM 
KeyboardPowerCaseMouse
Logitech K740 Seasonic G 550W Fractal Define R4 - Black with window Logitech M705 
Mouse PadAudio
Fellowes PlushTouch ASUS Xonar DGS with HD595s and Altec Lansing FX... 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Intel i5-4670K MSI Z87-G41 ASUS GTX 660 Corsair 8GB 
Hard DriveOptical DriveOSMonitor
9TB  None Windows 7 Dell U2713HM 
KeyboardPowerCaseMouse
Logitech K740 Seasonic G 550W Fractal Define R4 - Black with window Logitech M705 
Mouse PadAudio
Fellowes PlushTouch ASUS Xonar DGS with HD595s and Altec Lansing FX... 
  hide details  
Reply
post #2 of 4
Looks like your best bet is this: http://www.daveamenta.com/2011-05/programmatically-or-command-line-change-the-default-sound-playback-device-in-windows-7/

It's not ideal, but it's much better than simulating keystrokes. It sucks that MS doesn't have a simple API for switching the device since so many people hook their PCs up to lots of things now.
The New Guy
(16 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0@3.0GHz GA-P35-DS3L EVGA 8800GT Superclocked 4GB Corsair XMS2 DDR2 800 
Hard DriveHard DriveOptical DriveOS
Seagate 320GB 7200RPM Western Digital Caviar Black Lite-on DVD burner Windows 7 Professional x64 
MonitorKeyboardPowerCase
Samsung 225BW Filco Majestouch Ninja (full keyboard w/browns) Cooler Master Xtreme 650 Antec 900 
MouseAudioAudio
Logitech MX518 Denon AHD-2000 Sennheiser HD595 
  hide details  
Reply
The New Guy
(16 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0@3.0GHz GA-P35-DS3L EVGA 8800GT Superclocked 4GB Corsair XMS2 DDR2 800 
Hard DriveHard DriveOptical DriveOS
Seagate 320GB 7200RPM Western Digital Caviar Black Lite-on DVD burner Windows 7 Professional x64 
MonitorKeyboardPowerCase
Samsung 225BW Filco Majestouch Ninja (full keyboard w/browns) Cooler Master Xtreme 650 Antec 900 
MouseAudioAudio
Logitech MX518 Denon AHD-2000 Sennheiser HD595 
  hide details  
Reply
post #3 of 4
Thread Starter 
Quote:
Originally Posted by Desidero View Post

Looks like your best bet is this: http://www.daveamenta.com/2011-05/programmatically-or-command-line-change-the-default-sound-playback-device-in-windows-7/

It's not ideal, but it's much better than simulating keystrokes. It sucks that MS doesn't have a simple API for switching the device since so many people hook their PCs up to lots of things now.

Thanks for the reply. I'm afraid I'm new to this stuff., and don't know where to begin.

How do I do this? Is it asking me to edit my windows files?
    
CPUMotherboardGraphicsRAM
Intel i5-4670K MSI Z87-G41 ASUS GTX 660 Corsair 8GB 
Hard DriveOptical DriveOSMonitor
9TB  None Windows 7 Dell U2713HM 
KeyboardPowerCaseMouse
Logitech K740 Seasonic G 550W Fractal Define R4 - Black with window Logitech M705 
Mouse PadAudio
Fellowes PlushTouch ASUS Xonar DGS with HD595s and Altec Lansing FX... 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Intel i5-4670K MSI Z87-G41 ASUS GTX 660 Corsair 8GB 
Hard DriveOptical DriveOSMonitor
9TB  None Windows 7 Dell U2713HM 
KeyboardPowerCaseMouse
Logitech K740 Seasonic G 550W Fractal Define R4 - Black with window Logitech M705 
Mouse PadAudio
Fellowes PlushTouch ASUS Xonar DGS with HD595s and Altec Lansing FX... 
  hide details  
Reply
post #4 of 4
He includes a zip file with the exe and source code/visual studio solution at the bottom of the page (http://www.daveamenta.com/download/AudioEndPointController.zip)

Once you have that, just run the exe with no arguments to list devices or provide the number to switch the default. I tested it in Windows 8 Pro, and it works. As the author mentions, this uses an undocumented API, so it could potentially break in the future. Be careful with it.

The New Guy
(16 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0@3.0GHz GA-P35-DS3L EVGA 8800GT Superclocked 4GB Corsair XMS2 DDR2 800 
Hard DriveHard DriveOptical DriveOS
Seagate 320GB 7200RPM Western Digital Caviar Black Lite-on DVD burner Windows 7 Professional x64 
MonitorKeyboardPowerCase
Samsung 225BW Filco Majestouch Ninja (full keyboard w/browns) Cooler Master Xtreme 650 Antec 900 
MouseAudioAudio
Logitech MX518 Denon AHD-2000 Sennheiser HD595 
  hide details  
Reply
The New Guy
(16 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0@3.0GHz GA-P35-DS3L EVGA 8800GT Superclocked 4GB Corsair XMS2 DDR2 800 
Hard DriveHard DriveOptical DriveOS
Seagate 320GB 7200RPM Western Digital Caviar Black Lite-on DVD burner Windows 7 Professional x64 
MonitorKeyboardPowerCase
Samsung 225BW Filco Majestouch Ninja (full keyboard w/browns) Cooler Master Xtreme 650 Antec 900 
MouseAudioAudio
Logitech MX518 Denon AHD-2000 Sennheiser HD595 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Help a newb with this script