I'm coding a program and I wanted to change the operating system volume.
I went about this using the pyautogui module.
import pyautogui
pyautogui.PAUSE = 0 # changes the time pyautogui waits before doing another thing
user_input = input("Please type in the volume you want: ") # ask the user for the volume they want
# reset the volume to 0 by pressing volume down 50 times
for _ in range(50):
pyautogui.press("volumedown")
# set the volume to the specified amount by pressing volume up for input // 2
for _ in range(int(user_input)//2):
pyautogui.press("volumeup")
print(f"I set the volume to {user_input}.")
This code has many flaws. First it can only set the volume to even numbers. And pyautogui conflicts with tkinter, which is essential for the program I am making. Is there any way to set the windows/os volume using a module that does it directly? Thanks