PC Review


Reply
Thread Tools Rate Thread

What should be the WPARAM and LPARAM

 
 
Anand Ganesh
Guest
Posts: n/a
 
      19th Feb 2008
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


 
Reply With Quote
 
 
 
 
Peter Duniho
Guest
Posts: n/a
 
      19th Feb 2008
On Tue, 19 Feb 2008 11:41:48 -0800, Anand Ganesh
<(E-Mail Removed)> wrote:

> 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
 
Reply With Quote
 
 
 
 
Anand Ganesh
Guest
Posts: n/a
 
      19th Feb 2008
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


"Peter Duniho" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> On Tue, 19 Feb 2008 11:41:48 -0800, Anand Ganesh
> <(E-Mail Removed)> wrote:
>
>> 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



 
Reply With Quote
 
Peter Duniho
Guest
Posts: n/a
 
      19th Feb 2008
On Tue, 19 Feb 2008 12:13:34 -0800, Anand Ganesh
<(E-Mail Removed)> wrote:

> 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
 
Reply With Quote
 
Willy Denoyette [MVP]
Guest
Posts: n/a
 
      19th Feb 2008
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.



"Anand Ganesh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
> "Peter Duniho" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
>> On Tue, 19 Feb 2008 11:41:48 -0800, Anand Ganesh
>> <(E-Mail Removed)> wrote:
>>
>>> 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

>
>



 
Reply With Quote
 
Anand Ganesh
Guest
Posts: n/a
 
      19th Feb 2008
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


"Peter Duniho" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> On Tue, 19 Feb 2008 12:13:34 -0800, Anand Ganesh
> <(E-Mail Removed)> wrote:
>
>> 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



 
Reply With Quote
 
Anand Ganesh
Guest
Posts: n/a
 
      20th Feb 2008
Thank you Willy for the tips. I will consider this when speaking to my
clients.

Thanks
Anand

"Willy Denoyette [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>
>
>
> "Anand Ganesh" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>>
>>
>> "Peter Duniho" <(E-Mail Removed)> wrote in message
>> news(E-Mail Removed)...
>>> On Tue, 19 Feb 2008 11:41:48 -0800, Anand Ganesh
>>> <(E-Mail Removed)> wrote:
>>>
>>>> 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

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing A Float In WParam or LParam of Windows Message dzar Microsoft C# .NET 7 18th Apr 2007 04:02 AM
WM_LBUTTONDOWN and the lParam parameter Nick Microsoft VB .NET 3 10th Jan 2006 04:28 PM
Help with Select statement with WParam vbmark Microsoft Dot NET Compact Framework 2 14th Feb 2005 05:38 PM
Most significant bit in WM_COMMAND wparam Just Me Microsoft C# .NET 4 7th Feb 2005 10:17 PM
How will I get wparam inside VC++.NET =?Utf-8?B?U3JlZWppdGggUCBT?= Microsoft Dot NET 0 25th Feb 2004 08:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:53 PM.