josetr / AudioDeviceSwitcher

Audio Device Switcher is a Windows 10 app that makes it easy to quickly switch your default playback device as well as your recording device using hotkeys.
https://www.microsoft.com/en-us/p/audio-device-switcher/9n71nh5h6t7k?activetab=pivot:overviewtab
Other
26 stars 1 forks source link

Media buttons as Hotkey #1

Closed adem404 closed 2 years ago

adem404 commented 2 years ago

Is it possible to listen to media buttons? Here are the Virtual-Key Codes, if it helps:

VK_MEDIA_NEXT_TRACK | 0xB0 | Next Track key -- | -- | -- VK_MEDIA_PREV_TRACK | 0xB1 | Previous Track key

https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes

josetr commented 2 years ago

Hi. It is possible to register a hotkey for such media buttons but the reason why it doesn't work is that we are using UIElement.ProcessKeyboardAccelerators to detect the initial combination before actually registering it and this event is not called for those buttons and probably a few others. My guess is that it doesn't consider them as valid accelerators or keyboard shortcuts.

Manually detecting this odd combination using events like UIElement.KeyDown is certainly possible but this is more error-prone than what we've got.

josetr commented 2 years ago

Perhaps the bigger issue I see is that registering a hotkey with such a combination won't stop other applications such as Spotify from handling these media buttons and the outcome isn't pretty: you will change the audio device, but also your current song.

adem404 commented 2 years ago

I forgot about the Spotify integration of the media keys maybe because i dont use them. Some years ago i used this application back then i think the media keys got registred as input. But time pass and api changes. Thx for the reply.

josetr commented 2 years ago

No problem. Do note that currently, it's not even possible to disable the media keys in Spotify (https://community.spotify.com/t5/Desktop-Windows/How-to-disable-Hardware-Media-Key/td-p/4966916) so I'm gonna this issue for now.