How to control the volume of windows microphone with python?

problem description

use python to control the microphone volume of the windows system. The startup program automatically adjusts the microphone volume to 50%.

to use python to do a function similar to QQ recording detection, I have seen that Pyaudio, can achieve recording function. Then we found that win32.api, can finally control the sound of the loudspeaker.

related codes

import win32api
WM_APPCOMMAND = 0x319

APPCOMMAND_VOLUME_MAX = 0x0a
APPCOMMAND_VOLUME_MIN = 0x09

maximum volume
win32api.SendMessage (- 1, WM_APPCOMMAND, 0x30292, APPCOMMAND_VOLUME_MAX * 0x10000)

minimum volume
win32api.SendMessage (- 1, WM_APPCOMMAND, 0x30292, APPCOMMAND_VOLUME_MIN * 0x10000)

I want to adjust the volume of the microphone.

Jul.27,2021

APPCOMMAND_MICROPHONE_VOLUME_DOWN
25
increase the microphone volume.

from: https://docs.microsoft.com/zh.

Menu