I have a small script I want to have running in the background that would pause Spotify music if any other program starts playing audio - e.g. video, browser, game..
I got the spotify part working even without their API using win32api and SendMessage, however I can't seem to find any way of cheching whether other programs are playing audio.
I tried looking at windows mixer, maybe even at the jack connector, nothing..
Here's the code for it, but it's missing the check function and a loop
Bonus point, if you seen a program that does this thing, I'm all for it, it was even suggested to Spotify but they never responded.
def f_click(pycwnd):
x=800
y=840
lParam = y << 16 | x
pycwnd.SendMessage(win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON, lParam);
pycwnd.SendMessage(win32con.WM_LBUTTONUP, 0, lParam);
def get_whndl():
whndl = win32gui.FindWindowEx(0, 0, None, 'Spotify Premium')
return whndl
def make_pycwnd(hwnd):
PyCWnd = win32ui.CreateWindowFromHandle(hwnd)
return PyCWnd
whndl = get_whndl()
pycwnd = make_pycwnd(whndl)
f_click(pycwnd)