What should be the WPARAM and LPARAM

  • Thread starter Thread starter Anand Ganesh
  • Start date Start date
A

Anand Ganesh

Hello Everybody,

I want to give a Windows 32 API SendMessage command to Windows Media Player
and Pause it or Play it.

The shortcut command is Control-P.

What is the hexadecimal value I should use and how can I find this?

I found out WM_KEYDOWN is 0x100 and WM_KEYUP is 0x101. Hope this right.

Any suggestions please?

Thanks
Anand
 
I want to give a Windows 32 API SendMessage command to Windows Media
Player
and Pause it or Play it.

The shortcut command is Control-P.

You might instead find the SendKeys class preferable.

Pete
 
Peter,

I am trying to control Windows Media Player from a seperate .NET
Application.

I am using Windows 32 API.

SendKeys is for Windows Forms but using this I cannot access a different
process.

Please let me know whether I am missing something here.

I thought only Windows 32 API is the best way to access another process.

Thanks for your time.

Regards
Anand Ganesh
 
I am trying to control Windows Media Player from a seperate .NET
Application.

I am using Windows 32 API.

SendKeys is for Windows Forms but using this I cannot access a different
process.

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
 
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.
 
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
 
Thank you Willy for the tips. I will consider this when speaking to my
clients.

Thanks
Anand
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top