Setting playback device by executing a batch file / powershell script

后端 未结 6 1320
太阳男子
太阳男子 2021-01-31 04:21

I\'ve got my computer(Windows 7) hooked up to the TV, and i very often change output device for sound between Digital Audio (S/PDIF)(High definition audio device) and my headset

6条回答
  •  隐瞒了意图╮
    2021-01-31 05:20

    To follow up on Dale Newton's post, NirCmd is a great way to do this. On top of that if you pair it with AutoHotKey you can create an executable that will change your devices without opening pesky CMD windows every time you run it. For example, I have two sources that I switch between all the time, one is my headphones and they other is my monitor. For my monitor I created an ahk script that does this:

    #NoEnv
    SendMode Input
    SetWorkingDir %A_ScriptDir% ;I have nircmd in the same folder as these scripts
    Run, nircmd setdefaultsounddevice "Acer X34-8" 1
    Run, nircmd setdefaultsounddevice "Acer X34-8" 2
    

    And another for my headphones with the last two lines changed to:

    Run, nircmd setdefaultsounddevice "Headset Earphone" 1
    Run, nircmd setdefaultsounddevice "Headset Earphone" 2
    

    Afterwards you can compile each ahk script into an exe and bind each exe to a keyboard macro so you can execute them with a couple key presses. Personally I am using a Corsair K95 so I use their software to bind these to my 'G' keys.

    Also to note, if you are in your sound preferences you can rename any of the devices to avoid naming conflicts.

提交回复
热议问题