-
July 27th, 2011, 06:26 PM
#1
Handling special multimedia keyboard keys
Hi, I'm writing an app where I need to handle the play, pause, stop buttons on multimedia keyboards. I get the WM_APPCOMMAND events while my app has focus and all is well.
However, when my app is not focused, it never sees the play/stop/etc. I read through Win32 doc for handling keyboard input and it hints under the heading "Keyboard Keys for Browsing and Other Functions" to use SetWindowsHookEX with WH_SHELL.
If I do that as a local thread hook, my app never sees keys while other apps have focus. I'm pretty sure registering as a global hook will work, BUT
1) The Win32 docs say never to do that for released software (just bad practice, but I know lots of software does)
2) I'm afraid of getting flagged by anti-virus software (the real reason I have reservations about this approach)
How realistic is my fear of running afoul of anti-virus software? I'm not setting a keyboard hook like a key logger would, so maybe a global WH_SHELL hook is more benign?
I've noticed that Microsoft Media Player gets Play/Stop keys when they aren't focused, and Spy tells me they get it through the WH_SHELL hook. Does that mean they have to have set a global hook?
Thanks all!
Gus
-
August 2nd, 2011, 11:41 AM
#2
Re: Handling special multimedia keyboard keys
I would try to use RegisterHotKey Function.
Check out Virtual-Key Codes, in particular VK_MEDIA_PLAY_PAUSE and other VK_MEDIA_...
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
August 2nd, 2011, 04:19 PM
#3
Re: Handling special multimedia keyboard keys
That works great. Thank you very much Validimir!
-
August 2nd, 2011, 08:48 PM
#4
Re: Handling special multimedia keyboard keys
Originally Posted by maddoxrunner
That works great. Thank you very much Validimir!
you are welcome!
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|