I found out that you can control app volume by accessing Volume Mixer. Does anyone have any idea how to code/cmd/powershell to set an app volume by the user choice every time i log in/restart??
e.g. every time I restart my laptop, the volume of the WeChat app is maximised but I wish it to be only 2/100.
Any help will be appreciated!
To set your master Sound volume try
@echo off
Title Volume=2
(echo CreateObject("WScript.Shell"^).SendKeys "{" ^& chr(174^) ^&" 50}")>"%Temp%\%~n0.vbs"
(echo CreateObject("WScript.Shell"^).SendKeys "{" ^& chr(175^) ^&" 1}")>>"%Temp%\%~n0.vbs"
cscript //NoLogo "%Temp%\%~n0.vbs"
You could add that to your start-up sequence but that's another question that I will let you research. https://support.microsoft.com/en-us/windows/add-an-app-to-run-automatically-at-startup-in-windows-10-150da165-dcd9-7230-517b-cf3c295d89dd
Each volume unit is 2% so we go down 50 (max vol=100%) to zero then up one unit to 2%
Note by careful edit you could combine all those lines into one single "shortcut" in your startup, but again I will let you experiment.
For an audio feedback try these, to avoid any howling between microphone and speakers use/adjust second example
@echo off
Title Volume=2
(echo CreateObject("WScript.Shell"^).SendKeys "{" ^& chr(175^) ^&" 50}")>"%Temp%\%~n0.vbs"
(echo CreateObject("WScript.Shell"^).SendKeys "{" ^& chr(174^) ^&" 30}")>>"%Temp%\%~n0.vbs"
(echo CreateObject("SAPI.SpVoice"^).Speak ("Lowering volume to 2%%"^))>>"%Temp%\%~n0.vbs"
(echo CreateObject("WScript.Shell"^).SendKeys "{" ^& chr(174^) ^&" 20}")>>"%Temp%\%~n0.vbs"
(echo CreateObject("WScript.Shell"^).SendKeys "{" ^& chr(175^) ^&" 1}")>>"%Temp%\%~n0.vbs"
cscript //NoLogo "%Temp%\%~n0.vbs"
@echo off
Title Volume=20
REM CHR(173) is the MUTE ON/OFF key, CHR(174) is the VOLUME DOWN key & CHR(175) is VOLUME UP key.
REM The next value after steps +/- 2% units, so UP 50 times will force volume to the max first.
REM In some cases depending on other apps it may be safer to set to Zero=(174)50 1st then up&down.
REM For example set 1st to ZERO (-50) up to 50% (+25) for notification then say down to 20% (-15)
(echo CreateObject("WScript.Shell"^).SendKeys "{" ^& chr(174^) ^&" 50}")>"%Temp%\%~n0.vbs"
(echo CreateObject("WScript.Shell"^).SendKeys "{" ^& chr(175^) ^&" 25}")>>"%Temp%\%~n0.vbs"
(echo CreateObject("SAPI.SpVoice"^).Speak ("Lowering volume to 20%%"^))>>"%Temp%\%~n0.vbs"
(echo CreateObject("WScript.Shell"^).SendKeys "{" ^& chr(174^) ^&" 15}")>>"%Temp%\%~n0.vbs"
cscript //NoLogo "%Temp%\%~n0.vbs"
In response to the question "does it only control selected app, or the entire audio?"
It is emulating the windows system sound keys so affects overall system speakers. To focus an app is much more difficult unless it has a CLI switch like some audio apps have or an API value to target.
If you need greater control per app I suggest look at https://www.nirsoft.net/utils/app_audio_config.html
As an alternative there is the more basic command line tool "setvol" more suited to the command line but more difficult to use on a per application basis, however if weechat is listed as a "device" it can target its volume