> I am trying to control Windows Media Player from a seperate .NET
> Application.
[quoted text clipped - 5 lines]
>
> Please let me know whether I am missing something here.
Well, SendKeys works by sending the key information to the _active_
application. This may or may not be your own. It's whichever application
is in the foreground with input focus. You definitely can use SendKeys
with a process other than your own.
> I thought only Windows 32 API is the best way to access another process.
You'd still need the unmanaged API to bring the media player to the
foreground. It's just that SendKeys allows you to treat the key
information in a managed way.
If it's not appropriate for the media player to be the foreground, focused
application when you send the key data to it, then SendKeys isn't what you
want.
As for your original question: did you try those codes? Do they work as
you expect them to? If so, I'd say you got it right. If not, I'd say you
got it wrong.
I haven't bothered to figure out the codes myself, but IMHO the docs are
pretty clear on what should be sent. For WM_KEYDOWN and WM_KEYUP you'll
need to use the "VK" code for the P key in combination with the
appropriate code for the control key in order to generate the Control-P.
Note that by "in combination" I mean you need to generate the appropriate
messages for both keys.
I'm actually a bit surprised that there's no automation API for the
Windows Media Player. I'm assuming you've looked for such an API and was
unable to find it. If not, you might want to look into that as well. It
might be easier to be able to create a new WMP process instance from your
application that you can control directly rather than having to go through
the unmanaged API.
Sorry I don't know more about it. I was just trying to make sure you were
aware of the SendKeys class, in case that's something that was useful for
you.
Pete
Anand Ganesh - 19 Feb 2008 22:56 GMT
Thank you Peter,
Yes I tried to setfocus and used SendKeys and it worked !
Thanks for your tips and advice and your valuable time.
With best regards
Anand
>> I am trying to control Windows Media Player from a seperate .NET
>> Application.
[quoted text clipped - 44 lines]
>
> Pete
WMP comes with an automation compatible object model, that means you can
control Media Player from any language that supports COM automation.
To use it from C#, you simply need to
- add a COM reference to "Windows Media Player" (wmp.dll),
- add a using directive like:
using WMPLib;
and you can access the OM like this:
WindowsMediaPlayer mediaPlayer = new WindowsMediaPlayerClass();
mediaPlayer .openPlayer(@"someMediaFile");
....
Willy.
> Peter,
>
[quoted text clipped - 24 lines]
>>
>> Pete
Anand Ganesh - 20 Feb 2008 00:30 GMT
Thank you Willy for the tips. I will consider this when speaking to my
clients.
Thanks
Anand
> WMP comes with an automation compatible object model, that means you can
> control Media Player from any language that supports COM automation.
[quoted text clipped - 37 lines]
>>>
>>> Pete