Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

What should be the WPARAM and LPARAM

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anand Ganesh - 19 Feb 2008 19:41 GMT
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
Peter Duniho - 19 Feb 2008 19:47 GMT
> 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
Anand Ganesh - 19 Feb 2008 20:13 GMT
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 want to give a Windows 32 API SendMessage command to Windows Media
>> Player
[quoted text clipped - 5 lines]
>
> Pete
Peter Duniho - 19 Feb 2008 20:28 GMT
> 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
Willy Denoyette [MVP] - 19 Feb 2008 21:20 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.