Solved

Send keys to an inactive application: Automate MusicMatch Jukebox

Posted on 2003-10-31
20
1,084 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
  • 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
 
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 33

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now