AndreMiras / pycaw

Python Core Audio Windows Library
MIT License
385 stars 67 forks source link

Realease Volume Setter #26

Closed BenDektor closed 3 years ago

BenDektor commented 3 years ago

Is there a way to be able to change the volume of a certain application like "chrome.exe" by hand and by for example a programm input in python at the same time. Because when I am controlling the volume of the sound with my Python-Programm I am not able to change it in my Sound Mixer. At first when I stop the programm from running.

My current Programm: `from pycaw.pycaw import AudioUtilities, ISimpleAudioVolume

request = True

while True:

if request:
    user_input = float(input("Volume: "))/100

    if user_input > 1.0:
        user_input = 1.0
    elif user_input < 0:
        user_input = 0
    print(user_input)
    request = False

sessions = AudioUtilities.GetAllSessions()
for session in sessions:
    if session.Process and session.Process.name() == 'Spotify.exe':
        volume = session._ctl.QueryInterface(ISimpleAudioVolume)

        volume.SetMasterVolume(user_input, None)
        request = True

` Would there be a way to implement that into the code?

BenDektor commented 3 years ago

Solved it myself