Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to listen to windows events in C#?

I'm developing an lyrics related application and I need to listen to Windows Media Player Events. I watched windows events in "Accessible event watcher" and I found out that there's some events that WMP sends whenever it's state or current position changes. I searched and found this article on MSDN a How to set a Windows hook in Visual C# .NET but I couldn't make it work.

How can I listen to that events from my C# application or any suggestions on using other methods to get current song and WMP playing status?\

Thank You

like image 954
Reza Ahmadi Avatar asked Sep 08 '12 13:09

Reza Ahmadi


1 Answers

This article describes how to get the events using the AxWindowsMediaPlayer which is the underlying root of the windows media player system. You will see that the various state change events can be picked up normally.

http://msdn.microsoft.com/en-us/library/windows/desktop/dd562388(v=vs.85).aspx

You should be able to get a running instance from the windows ROT (Running objects table)?

http://www.darinhiggins.com/the-running-instance-of-windows-media-player/

Edit:

This is another way...

http://www.darinhiggins.com/gaining-access-to-a-running-instance-of-windows-media-player-in-vb-net/

like image 186
Visual Micro Avatar answered Nov 01 '22 12:11

Visual Micro