Global Media Keys Don't Work

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Global Media Keys Don't Work

Re: Global Media Keys Don't Work

by Peke » Fri May 04, 2018 5:18 pm

Good luck to us all.

Re: Global Media Keys Don't Work

by RandomEngy » Fri May 04, 2018 2:59 pm

Re: Global Media Keys Don't Work

by Peke » Fri Apr 27, 2018 2:46 pm

Exactly as I explained earlier

My App hooks to driver low level and thus determine device events (HID = Human Interface Device https://en.wikipedia.org/wiki/Human_interface_device ) and by that I'm able to detect key press but as you noticed HID_DATA is Empty which means it is handled and cleared by some app :( Solving such issue usually require Elevated System resource Access and I personally DO NOT LIKE those annoying UAC prompts for no obvious reasons.

Re: Global Media Keys Don't Work

by RandomEngy » Wed Apr 25, 2018 2:07 pm

This is the log when I press the pause/play button with VS in foreground:
--------
Device ID: 131141
HID_DATA[1]: 0
Hotkey:
--------
Device ID: 131141
HID_DATA[1]: 0
Hotkey:
And when another app is in FG:
--------
Keyboard ID: 0
Pressed Key: MEDIA PLAY PAUSE
VKey ID: 00B3
State Flags: 0002
HotKey: MEDIA PLAY PAUSE
--------
Keyboard ID: 0
Pressed Key: MEDIA PLAY PAUSE
VKey ID: 00B3
State Flags: 0003
HotKey: MEDIA PLAY PAUSE
It doesn't seem to block it all the time; I haven't narrowed down when it works and when it doesn't.

Re: Global Media Keys Don't Work

by Peke » Sun Nov 19, 2017 8:33 pm

Hi,
Than VS is blocking all legal Media Key bindings. You can do a test as I explained in http://www.mediamonkey.com/forum/viewto ... 41#p432741 and I'll give you exact reason and why.

Re: Global Media Keys Don't Work

by RandomEngy » Sun Nov 19, 2017 10:40 am

That setting doesn't help. The play/pause key still doesn't work in VS.

Re: Global Media Keys Don't Work

by Peke » Sun Nov 19, 2017 8:19 am

You can force low level hook for a keyboard by adding value "PreferLLKeysHook = 1" to the [options] section of MediaMonkey.ini file but that is override system design and how input is handled correctly see https://msdn.microsoft.com/en-us/librar ... s.85).aspx MMW corresponds to RIDEV_EXINPUTSINK but not all applications implement that correctly.

Re: Global Media Keys Don't Work

by RandomEngy » Sun Nov 19, 2017 1:57 am

Hmm, okay. But why can't you use the same API that Spotify is using that allows it to play/pause while VS is running?

Re: Global Media Keys Don't Work

by Peke » Sat Nov 18, 2017 7:22 pm

If MMW reacts while Spotify is foreground it looks like Spotify do not report MediaKey handled and MMW pick it up.

Re visual studio, See if you can disable low level keyboard hook in VS, I have had similar issue in Delphi in teh past when PLAY/PAUSE was assigned to Break app execution to debug.

Re: Global Media Keys Don't Work

by RandomEngy » Thu Nov 09, 2017 1:32 pm

I noticed that MediaMonkey ignores the play button when Visual Studio is active, but Spotify hears it. Spotify also hooks into the native Windows "Now playing" overlay UI. It also seems to behave better when both MediaMonkey and Spotify are open:

MediaMonkey in foreground and Spotify in background: MediaMonkey plays but Spotify doesn't do anything
Spotify in foreground and MediaMonkey in background: Both Spotify and MediaMonkey play at the same time

It would be really nice if you could have MediaMonkey act more like Spotify. I have Visual Studio open all the time and it drives me crazy that I can't use the keyboard to play and pause while working.

Re: Global Media Keys Don't Work

by Peke » Mon Feb 27, 2017 8:43 am

Hi,
A bump to the topic. I've found that WMP actually do not comply with any rules Microsoft put in the first place eg. simple it reacts on all media keys regardless Active application is handling the key or not so if I have for example started WMP, AIMP and MMW all having paused playback no matter if AIMP or MMW are active WMP reacts on Play/Pause Key even Active application already handled the key, which is not case with both AIMP and MMW which reacts according to rules that if Active application handle key then app in background do not execute it.

Why I was not surprised about the result.

Re: Global Media Keys Don't Work

by Daires1 » Mon Feb 13, 2017 2:02 pm

Thank you again Peke for the detailed answer.

I understand the problem now and I tested the hotkeys with teamspeak in the background, they work. This is fine to me, but is there any solution to make them also work in a focused game?
Windows Media Player works ingame, so I would assume it is possible or does it handle hotkeys differently than MediaMonkey?

Greetings!

Re: Global Media Keys Don't Work

by Peke » Sun Feb 12, 2017 7:15 pm

Hi,
Thx for testing, there is a pattern. Let me try to explain.

Code: Select all

Device ID: HARDWARE ID 
HID_DATA[1]: HARDWARE RAW Data sent by Device Event (in this case key press, but can be different depending on device)
Hotkey: HOTKEY TRANSLATION OF HID_DATA[1] Driver based 
Keyboard ID: ID of Keyboard in case of multiple keyboards (If you add external NUMPAD to Laptop or BARCODE Reader for example) so that system knows which keyboard sent key
Pressed Key: MEDIA PLAY PAUSE (System Command name Sent for pressed key) 
VKey ID: 00B3 (SYSTEM KEY ID)
State Flags: 0002 (Event state that sent KEY Values eg. On Press/Release)
HotKey: MEDIA PLAY PAUSE (Actual KEY Pressed)
Now pattern:
Ingame: Game locks keyboard events on driver Level so only RAW DATA is passed which is then sent to driver -> Handled by GAME -> Cleared so that game waits for next command and No command is passed to system to be handled. This approach lowers response LAG but locks out other apps
Firefox: Same as ingame, but as Firefox is not set to handle that key it then forward to system that sends wide event to handle HOTKEY and that is why MMW reacts
Desktop: System handles RAW DATA Directly and translate it to Keyboard events and MMW knows that it needs to react
teamspeak: Same as Ingame in order to work ingame teamspeak handle the Key like ingame and as Focused APP (GAME) also gets same event it works. Only way to override ingame and have Push to talk work.
uplay: After handling hotkey it forwards the key to Registered apps (eg. MediaMonkey) which should handle the key. Logger is not registered application for any key but global event watcher
Logger: Focused command param receive to execute assigned System Command APPCOMMAND_MEDIA_PLAY_PAUSE and Handle it. It is SET in logger to report Key handled instead forward the command like Firefox, and MMW comply with that rule and do not react (eg. Command handled in other application do not execute)
MMW: Logger is disabled to fetch any key MMW already handled.

Hope I cleared things a bit.

Have you tried to have teamspeak in background and MMW focused, keys should work.

Personally I find Ingame and teamspeak behavior a hack workaround to ensure working and low LAG but I can relate why they done that in such manner.

Re: Global Media Keys Don't Work

by Daires1 » Sun Feb 12, 2017 11:38 am

Hello Peke,

thank you for your reply.

The following is logged ingame after pressing the media key play/stop:

Code: Select all

--------
Device ID: 65576
HID_DATA[1]: 3CD00
Hotkey: 
--------
Device ID: 65576
HID_DATA[1]: 30000
Hotkey: 
--------
MediaMonkey does not react.

The following is logged in firefox after pressing the media key play/stop:

Code: Select all

-------
Device ID: 65576
HID_DATA[1]: 3CD00
Hotkey: 
--------
Keyboard ID: 0
Pressed Key: MEDIA PLAY PAUSE
VKey ID: 00B3
State Flags: 0002
HotKey: MEDIA PLAY PAUSE
--------
Device ID: 65576
HID_DATA[1]: 30000
Hotkey: 
--------
Keyboard ID: 0
Pressed Key: MEDIA PLAY PAUSE
VKey ID: 00B3
State Flags: 0003
HotKey: MEDIA PLAY PAUSE
MediaMonkey does react.

The following is logged on desktop after pressing the media key play/stop:

Code: Select all

--------
Keyboard ID: 0
Pressed Key: MEDIA PLAY PAUSE
VKey ID: 00B3
State Flags: 0002
HotKey: MEDIA PLAY PAUSE
--------
Keyboard ID: 0
Pressed Key: MEDIA PLAY PAUSE
VKey ID: 00B3
State Flags: 0003
HotKey: MEDIA PLAY PAUSE
MediaMonkey does react.

The following is logged in teamspeak after pressing the media key play/stop:

Code: Select all

--------
Device ID: 65576
HID_DATA[1]: 3CD00
Hotkey: 
--------
Device ID: 65576
HID_DATA[1]: 30000
Hotkey: 
MediaMonkey does not react.

The following is logged in uplay after pressing the media key play/stop:

Code: Select all

--------
Device ID: 65576
HID_DATA[1]: 3CD00
Hotkey: 
--------
Device ID: 65576
HID_DATA[1]: 30000
Hotkey: 
MediaMonkey does react.

Also interesting, if the key logger is focused:

Code: Select all

--------
Device ID: 65576
HID_DATA[1]: 3CD00
Hotkey: 
--------
Keyboard ID: 0
Pressed Key: MEDIA PLAY PAUSE
VKey ID: 00B3
State Flags: 0002
HotKey: MEDIA PLAY PAUSE
--------
Param CMD: 14
Param: APPCOMMAND_MEDIA_PLAY_PAUSE
--------
Device ID: 65576
HID_DATA[1]: 30000
Hotkey: 
--------
Keyboard ID: 0
Pressed Key: MEDIA PLAY PAUSE
VKey ID: 00B3
State Flags: 0003
HotKey: MEDIA PLAY PAUSE
But MediaMonkey does not react.

And if I focus MediaMonkey itself the keylogger does not log any key but MediaMonkey reacts.

I for myself can not see a pattern here.

Re: Global Media Keys Don't Work

by Peke » Sat Feb 11, 2017 5:08 pm

The only way it can happen and Have seen that when application uses Low Level Keys Hook and after non handling/handling it clears system flag that key is pressed.

Can you confirm that with http://www.happymonkeying.com/eSupport/hotkey.zip in background you still read key in games?

Top