Send keys to an inactive application: Automate MusicMatch Jukebox

I want to be able to tell MusicMatch Jukebox to PAUSE using the keyboard's Pause/Break key, even when MMJB is not the active application.

This seems like it ought to be easy enough to do, but several attempts (SendKeys, postmessage, etc) have failed.  The key point is that it needs to work when MMJB doesn't have the Windows keyboard focus.  I've tried to use the "Hotkeys Utility" v.1.3 by Arjen Broeze:  

http://216.239.39.104/search?q=cache:EH38Q3VRKGcJ:www.torry.net/util_system.htm+write+delphi+software+that+works+through+firewalls&hl=en&ie=UTF-8

...but that has the same problem (at least under 2000 and XP) - the target application must have the keyboard focus.

I've also considered using OLE automation, but I haven't found any documentation on the DDE server within MMJB (assuming there is one).  A third possiblity is controlling MMJB through the MMJB QuickPlay tray app, but I haven't got a clue where to start down that road.

This need first started when I purchased a KeySpan IR Remote Control.  It woked fine when MMJB was the current application, but it refused to control MMJB if any other program was focused.  Contacting KeySpan was a dead end (I believe they are now, justifiably, out of business!).  So now I want to do it myself.  If anything can get it done DELPHI can!  Any ideas?
TValleyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nestoruaCommented:
HI,
You can use for example Tom Henderson technique (SendKeys32.pas).
Sincerely,
Nestorua.
0
TValleyAuthor Commented:
Nestorua,

Thanks for the tip.  It took a bit to find (Google only had two refernces!), but I downloaded it.  This has promise - especially combined with the included AppActivate routine.

I'll need a day or two to test it.  I'll let you know how it goes.

-TV
0
DeerBearCommented:
Hi,

I don't know this program, thus I may be wrong but... I assume there's a
"Stop" button in that app, thus you should be able to send a mouse click in
code like this:

begin
  PostMessage( BtnHwnd,WM_LBUTTONDOWN,0,0 );
  PostMessage( BtnHwnd,WM_LBUTTONUP,0,0 );
end;

To find the button use the EnumChildWindows API.

HTH,

Andrew

P.S. Sorry if you already gave this a try.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

nestoruaCommented:
Sure, first you must find the Handle of the main window (FindWindow procedure, f.e.).
Then to enumerate all its Child Windows to find the Handle of the specific Window
(EnumChildWindows procedure), some Button, if I'm not mistaken.
Then you can send Key strokes to that specific window (keybd_event function f.e.)
0
TValleyAuthor Commented:
Andrew,

I considered your approach, but (mysteriously) MusicMatch's buttons all have the exact same name (AfxOleControl70u), just with different handles - a result of it having changeable "skins" no doubt.

Perhaps the "Ole" part of the name is a clue that MusicMatch contains an automation server?

Any other ideas?

-TV
0
paulb1989Commented:
MMJB works with multimedia keyboards (with play controls on top) so if you can simulate a keypress of a key from a multimedia keyboard, it might work.
0
paulb1989Commented:
Just tested, and it works with multimedia keyboards when it isn't the active window aswell.
0
TValleyAuthor Commented:
Your comments sent me to information on Microsoft's Hot Keys interface.  Here's what I've been testing, but it's not working.  Any other ideas?  

const
  WM_APPCOMMAND               = $0319;
  APPCOMMAND_MEDIA_PLAY_PAUSE = 14;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  SendMessage(HWND_BROADCAST, WM_APPCOMMAND, Handle, APPCOMMAND_MEDIA_PLAY_PAUSE);
end;


I've also tried:
   SendMessage(Handle, WM_APPCOMMAND, Handle, APPCOMMAND_MEDIA_PLAY_PAUSE);

0
Slick812Commented:
have you tried this

keybd_event(VK_PAUSE,0,0,0);
keybd_event(VK_PAUSE,0,KEYEVENTF_KEYUP,0);
0
TValleyAuthor Commented:
That doesn't seem to work either.

Just to be certain the problem isn't with MusicMatch JB, I also started up Windows Media Player and repeated all of the tests - no go.  One would hope that MS's own player would support APPCOMMAND, so there must be something wrong in my technique or the commands that I'm sending.

-TV
0
TValleyAuthor Commented:
I'm doubling the points on this, since it has turned out to be harder to solve than first expected.

Any takers?

TIA,

-TV
0
DeerBearCommented:
Hi,

Given they have the same name, there must be something distinguishing them, no doubt.
Have you tried to examine their create data? Ya know, the custom data section of the
Window... maybe examining that you may find a recurring pattern... possible?

I'd guess it's some sort of Tag property.

HTH,

Andrew
0
TValleyAuthor Commented:
Interesting...  

I started up WinDowse to take another look at the MMJB window, and discovered, under "Modules", that theres an "mmjbctrl.ocx" loaded!!!!  Hmmmm...

[Later]
A binary scan of the OCX doesn't look very promising.  I'll see what I can figure out from it, though.

0
IamNewbieCommented:
Hello. I think u must create a "SendKeys" application, and then post key messages to Jukebox. FindWindow of Jukebox, and then send WM_KEY, or WM_CHAR to this. If you increase points, I will write this for you. Sorry, I have not many points, and time too. If you want, I will write it about 3-4 days. Can you mail me this Juke box, or give me URL for download.
0
TValleyAuthor Commented:
I appreciate the offer, but this goes beyond SendKeys, mainly because finding the window for the Jukebox becomes more difficult since the TITLE changes every time a new song starts (the titlebar/window name contains the song title).  As you can see from the thread, several SendKeys-like attempts have already been tried, with no success.

Any other ideas?

-TV
0
DeerBearCommented:
Hi TValley,

You say that the Title changes each time a new song is being played.
How about the class name? Does that change as well? <g>
I don't think so!

You can try with GetClassName API and EnumWindows in order to
find it each time.

Where can I download this weird APP?

I'd like to inspect it a bit and see what I can do to automate it.

HTH,

Andrew
0
TValleyAuthor Commented:
Andrew,

You're right, the Classname doesn't change ("MMJB:MAINWIND").

MMJB is available at:

http://www.musicmatch.com/

I'm using the "Plus" version with the "Zephyr" skin, but the free version should be the same as far as control goes.

Give it a go and let me know what you think.

-TV
0
IamNewbieCommented:
so...... what about sendkeys now? :-)))
0
moduloCommented:
PAQed with points refunded (200)

modulo
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.