I have WH-1000XM3 Bluetooth Headphones and I am trying to register, when I press the play/pause button on them. I am on Windows 10.
I come from this question, but it sadly just asks for the Multimedia keys on the keyboard.
It's possible to register these key presses with the following code with the pynput library:
from pynput import keyboard
def on_press(key):
if key == keyboard.Key.media_play_pause:
# Play/Pause Key
with keyboard.Listener(on_press=on_press) as listener:
listener.join()
This works for the button "media_play_pause"-Button in pynput.keyboard.Keys, but sadly the input from my Bluetooth headphone isn't recognized as that button. In fact, it isn't recognized as any button, the on_press function (as well as an on_release function) is not triggered when the Play/Pause button of the headphones is pressed.
So I guess the pynput library doesn't help.
Do you know a way to recognize the play/pause of content when a button is pressed or even know how to "simulate" a program to accept inputs from Bluetooth Headphones (like my Browser or my music program is doing for example)?
The goal is to trigger a function that executes a hotkey with pyautogui or a similar library.