Home > Blockchain >  Any way to invoke this Windows volume up/down window through Python?
Any way to invoke this Windows volume up/down window through Python?

Time:12-11

enter image description here

Any way to actually call this Windows volume window through Python?

I know that I can use pycaw to change the volume itself, I've done that already. I need help to call this one.

CodePudding user response:

With pywin32 you can send key board input for VK_VOLUME_UP/VK_VOLUME_DOWN, the key message will bring up that annoying window, example

import win32con
import win32api
import time

win32api.keybd_event(win32con.VK_VOLUME_UP, 0)
win32api.keybd_event(win32con.VK_VOLUME_UP, 0, win32con.KEYEVENTF_KEYUP)
time.sleep(1) #sleep is just to see the effect, it's not required here

win32api.keybd_event(win32con.VK_VOLUME_DOWN, 0)
win32api.keybd_event(win32con.VK_VOLUME_DOWN, 0, win32con.KEYEVENTF_KEYUP)
time.sleep(1)
  • Related