?
Solved

Send keys to an inactive application: Automate MusicMatch Jukebox

Posted on 2003-10-31
20
Medium Priority
?
1,092 Views
Last Modified: 2007-12-19
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?
0
Comment
Question by:TValley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 3
  • 2
  • +4
20 Comments
 
LVL 4

Expert Comment

by:nestorua
ID: 9662423
HI,
You can use for example Tom Henderson technique (SendKeys32.pas).
Sincerely,
Nestorua.
0
 

Author Comment

by:TValley
ID: 9662475
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
 
LVL 5

Expert Comment

by:DeerBear
ID: 9662502
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:nestorua
ID: 9662538
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
 

Author Comment

by:TValley
ID: 9662627
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
 
LVL 5

Expert Comment

by:paulb1989
ID: 9662896
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
 
LVL 5

Expert Comment

by:paulb1989
ID: 9662904
Just tested, and it works with multimedia keyboards when it isn't the active window aswell.
0
 

Author Comment

by:TValley
ID: 9664511
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
 
LVL 34

Expert Comment

by:Slick812
ID: 9664926
have you tried this

keybd_event(VK_PAUSE,0,0,0);
keybd_event(VK_PAUSE,0,KEYEVENTF_KEYUP,0);
0
 

Author Comment

by:TValley
ID: 9665442
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
 

Author Comment

by:TValley
ID: 9669787
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
 
LVL 5

Expert Comment

by:DeerBear
ID: 9669889
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
 

Author Comment

by:TValley
ID: 9670027
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
 

Expert Comment

by:IamNewbie
ID: 9677006
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
 

Author Comment

by:TValley
ID: 9678095
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
 
LVL 5

Expert Comment

by:DeerBear
ID: 9678185
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
 

Author Comment

by:TValley
ID: 9678814
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
 

Expert Comment

by:IamNewbie
ID: 9678885
so...... what about sendkeys now? :-)))
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12694298
PAQed with points refunded (200)

modulo
Community Support Moderator
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question