Jump to content

Physical switch to change Windows default audio device

Randeeeezy

Hi all,

 

I'm interested in making a physical switch that will toggle between two different windows audio devices, and I'm not sure exactly what would be required.

 

I'm running windows 7, and the two devices I'm using are an HDMI connection to my TV, and a USB Bluetooth dongle to my headset. I want to wire this switch to my desk, and have it toggle between the two. I know people have created quick buttons that control this, but I have been working on creating my first desk, with usb and cup holders and LED lights and would really like to wire a control that toggles these devices.

 

I own a couple Arduino nano's (knockoffs from banggood), and three Raspberry Pi's (two model b and one model a, I believe), however I have never gotten into learning how to code them yet. I also know how to do any soldering for the switch that will be required.

 

What I'm hoping to get help with is what exactly would be required to create this switch. I imagine it would require the switch being attached to the nano/rpi and the rpi being coded to trigger the PC to run these quick-switches that people have made, based on what signals the switch is sending to the rpi/nano.

 

Am I on the right track here? Can anyone help point me towards what code I should be learning to do?

 

Thanks in advance, and sorry for the wall of text, just wanted to give all the detail I could.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

This is going to be a bit fiddly, but here's how I'd do it. 

I already have an Autohotkey script which is doing the same thing that you want to achieve by pressing a combination of keys. I'd run that script in AHK with a very weird key combination and use a Teensy to convert your button press into that keyboard command. Your Arduinos aren't that great a HID and simulating keyboards. There is a library for Keyboard input for Arduinos, but it's only for the Due and the Zero. You can get it to work with your nanos, but you're better off getting a Teensy for 15$.

 

So to recap: Button is pressed -> Micro-controller converts button press into usable keyboard command and sends it via USB -> Keyboard command triggers AHK script which causes the Audio device to switch

 

Here is the Script that I use, I half wrote, half copied it a while ago:

 

^!Numpad0::   ; Keyboard shortcut
 toggle:=!toggle ;toggles up and down states. 
  Run, mmsys.cpl 
  WinWait,Sound ; Change "Sound" to the name of the window in your local language 
  if toggle
    ControlSend,SysListView321,{Down 1} ; This number selects the matching audio device in the list, change it accordingly 
  Else
    ControlSend,SysListView321,{Down 3} ; This number selects the matching audio device in the list, change it accordingly 
  ControlClick,&Als Standard ; Change "&Als Standard" to the name of the button in your local language 
  ControlClick,OK 
return

EDIT: If you really want to make it work with the Arduino, then there are ways but they are far more complicated than this solution. The reason I'm recommending the Teensy is that it is used by many to build diy mechanical keyboards which is technically what you're doing even though your keyboard only has one button 

Molex to SATA, lose all your data

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Thanks so much for the quick response. You said $15, so I assume that means I can get the 2.0, 8 bit?

I have a brother who will likely be able to help me get it all working, but I want to make sure I have all the parts we may need before I ask him to donate some time.

 

Thanks for the code, as well.

 

Link to comment
Share on other sites

Link to post
Share on other sites

You're welcome :D 

The Teensy 2.0 has the largest amount of community support as it has been the standard for DIY keyboards for a while now. You can get clones for around 15$ from Ebay but these aren't worth it when you can get an original for 16$ Here's some info  on the Teensy and where to get it https://deskthority.net/wiki/Teensy

Autohotkey is a bit weird at first but it's fantastic once you understand it and get it set up properly. 

You should ask your brother on some input. Maybe there's a much more simple solution than my idea. Have fun with the building and tinkering :) 

Molex to SATA, lose all your data

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×