Ankan Das
Ankan Das

Reputation: 298

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

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.

Upvotes: 0

Views: 1944

Answers (1)

Barmak Shemirani
Barmak Shemirani

Reputation: 31629

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)

Upvotes: 1

Related Questions