Old 18th March 2005, 02:06   #1
judge
Junior Member
 
judge's Avatar
 
Join Date: Dec 2001
Posts: 19
Media Keyboards?

Hi,

I'm trying to write an app that controls mp3 players by simulating the action of the media keyboards. Why? Well I want to be able to control a range of mp3 players with the one widget.

Anyhow, on the face of it I should be able to do this by posting a WM_APPCOMMAND message and windows will ensure that if the current window doesn't handle it it will be dispatched via the WH_SHELL hook to non-active windows.

Trouble is it doesn't work. For starters posting a WM_APPCOMMAND message controls WMP if it is not the active window, but it doesn't control Winamp. For seconds if I write an app that hooks WM_SHELL, it doesn't even respond to an actual real mdeia keyboard if the window is not active - never mind my WM_APPCOMMAND messages.

So to cut a long story short I was wondering if anyone can tell me how Winamp hooks a media keyboard when it is non-active. I know how to configure Winamp to do it - what I really want to know is the actual code it uses to do the hooking.

Thanks - Paul
judge is offline   Reply With Quote
Old 18th March 2005, 12:57   #2
eleet-2k2
Forum King
 
eleet-2k2's Avatar
 
Join Date: Aug 2001
Location: Mobil Ave.
Posts: 5,381
Why not just find the Winamp window reference, then fire a barrage of WM_COMMAND and WM_WA_IPC commands at it for control? That's what I'm doing for a very similar project.

"Welcome to the Island of people who know too much."..."Did you really think balloons would stop him?!"
See what I'm listening too.
eleet-2k2 is offline   Reply With Quote
Old 18th March 2005, 13:10   #3
judge
Junior Member
 
judge's Avatar
 
Join Date: Dec 2001
Posts: 19
Because I want the same app to control WMP and iTunes and anything else that responds to media keys.
judge is offline   Reply With Quote
Old 18th March 2005, 13:54   #4
tracerh
Banned
 
Join Date: Feb 2005
Posts: 84
i'm not 100% of sure what you're asking for?

Is BroadcastSystemMessage() in the right direction. Or do you want to make an actual system hook?
tracerh is offline   Reply With Quote
Old 18th March 2005, 16:35   #5
DrO
 
Join Date: Sep 2003
Posts: 27,873
RegisterHotKey is the win32 api used and Winamp doesn't handle wm_appcommand messages, just wm_command and wm_user.

-daz
DrO is offline   Reply With Quote
Old 18th March 2005, 16:56   #6
judge
Junior Member
 
judge's Avatar
 
Join Date: Dec 2001
Posts: 19
Quote:
Originally posted by tracerh
i'm not 100% of sure what you're asking for?

Is BroadcastSystemMessage() in the right direction. Or do you want to make an actual system hook?
Well I'm just trying to find out how this stuff really works.

For example, the msdn documentation for WM_APPCOMMAND msdn documentation for WM_APPCOMMAND imples that if the foreground app doesn't handle it the HSHELL_APPCOMMAND hook will be called. So I wrote a small test app to check this and it is certainly the case if the application is in the foreground, but it doesn't seem to work if the application is in the background.

Furthermore I wrote another app that posted WM_APPCOMMAND and it controlled WMP when WMP was in the background but it doesn't control Winamp.

So I was left wondering why hooking HSHELL_APPCOMMAND doesn't work, how WMP manages to hook my WM_APPCOMMAND messages and why Winamp doesn't manage to hook my WM_APPCOMMAND messages but does manage to hook the actual media keys on my keyboard when it isn't the active window
judge is offline   Reply With Quote
Old 18th March 2005, 17:02   #7
judge
Junior Member
 
judge's Avatar
 
Join Date: Dec 2001
Posts: 19
Quote:
Originally posted by DrO
RegisterHotKey is the win32 api used and Winamp doesn't handle wm_appcommand messages, just wm_command and wm_user.

-daz
Ahhh. Thanks.
judge is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump