Link to home
Start Free TrialLog in
Avatar of tdk_man
tdk_man

asked on

Controlling An External Windows Program From A Delphi App

Not sure if this is possible, but if you don't ask... :)

I want to call Winamp from my application and play some music while my app waits for Winamp to finish. This I have already done.

When the music ends and Winamp closes, control passes back to my app. This is OK, but what I want to do is to be able to press say the X key and close Winamp before the music has finished.

First thoughts suggest that it's not possible as my app loses focus when Winamp (set to Always On Top) is running, so there's nothing to process keystrokes. Am I right in thinking that pressing X would be intercepted by Winamp? If so, there doesn't appear to be a keyboard shortcut to exit Winamp (in the version I'm using anyway).

Any suggestions?

TDK_Man
Avatar of tdk_man
tdk_man

ASKER

Oops, sorry - forgot to mention that the Winamp video screen is also open (full screen) at the same time, so both Winamp and my app are hidden behind it and using the mouse to close it isn't an option.

TDK_Man
Avatar of philly_tee
Hi tdk_man,

Why don't you use Winamp's SDK?  It has commands for doing all sorts of stuff in it.

Regards,

Philip
What you are talking about is keyboard hooking. A simple way to do this is to assign using the following component libary, a hotkey (ctrl-x etc) so that no matter where you are when you press those keys an event is triggered in your application - you can get this component libary from:

http://homepages.borland.com/jedi/jvcl/

Use the hotkey component to assign a hotkey. Assign an event so you can close winamp or perform whatever action

Regards,

Hypoviax
Avatar of tdk_man

ASKER

Thanks for the info everyone, but the common problem seems to be that once Winamp has started, focus has been lost from my program and I cannot detect that a key has been pressed.

Once I can detect that I've pressed say the 'Q' key I can tell Winamp to close sending a message using FindWindow... I hope! :)

TDK_Man
ASKER CERTIFIED SOLUTION
Avatar of geobul
geobul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tdk_man

ASKER

Thanks for that geobul - just what I was after!

Info on closing the Winamp program itself I got after a quick search of past answers on EE and was amazed to find that the accepted answer was posted by my own son back in January 2000!

For anyone interested, it's done without the SDK with:

Sendmessage(hwndParent, WM_Close,0,0);

TDK_Man