Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, is it possible to get windows messages when my form doesn't have focus?

thank you for the reply, but I have a problem:
I have a Windows Forms Application not a Console Application and I modified the code to filter the messages:
protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == 0x0319)
            {
                MessageBox.Show("");
            }
        }

Now each time I press a button(like play, pause) on my Windows Media Center's remote control I should see a MessageBox. The code works fine when my form has focus but when I click another application(for example my browser) I don't see any more that MessageBox.

P.S. My application's goal is to make the remote control work with all the music/video players.
Posted
Updated 22-Aug-10 4:35am
v3

Yes.
C#
protected override void WndProc(ref Message m)
            {
            base.WndProc(ref m);
            Console.WriteLine(m.ToString());
            }


WARNING: Don't run this and expect good response times. You will get a lot of windows messages, and thus slow response because the console output will be scrolling like a loony!
 
Share this answer
 
Looks like you are building a spy application.
 
Share this answer
 
Comments
OriginalGriff 22-Aug-10 10:34am    
I hadn't noticed he had updated his question.

[deleted]Why? All he will get is his apps windows messages, not the messages for other apps. For that you need to use more complex hooking.[/deleted]
Toli Cuturicu 22-Aug-10 13:50pm    
Reason for my vote of 1
Not at all.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900