title: Receive OS level key-press events in C# application
body: <p>i dont know a better title for the question , but i`ll illustrate my problem.</p>
  
  <p>I am working on application that acts like a mp3 player , it uses the Multimedia keys to play/pause , stop the song , i actually made it work but the FormApplication must be in the top [Focused]</p>
  
  <pre><code>protected override void WndProc(ref Message msg)
  {
      if (msg.Msg == 0x319)   // WM_APPCOMMAND message
      {
          // extract cmd from LPARAM (as GET_APPCOMMAND_LPARAM macro does)
          int cmd = (int)((uint)msg.LParam &gt;&gt; 16 &amp; ~0xf000);
          switch (cmd)
          {
              case 13:  // APPCOMMAND_MEDIA_STOP constant
                  MessageBox.Show("Stop");
                  break;
              case 14:  // APPCOMMAND_MEDIA_PLAY_PAUSE
                  MessageBox.Show("Play/Pause");
                  break;
              case 11:  // APPCOMMAND_MEDIA_NEXTTRACK
                  MessageBox.Show("Next");
                  break;
              case 12:  // APPCOMMAND_MEDIA_PREVIOUSTRACK
                  MessageBox.Show("Previous");
                  break;
              default:  
                  break;
          }
      }
      base.WndProc(ref msg);
  }
  
  
  private void Form1_KeyPress(object sender, KeyPressEventArgs e)
  {
      Message m = new Message();
      m.Msg = e.KeyChar;
  
      WndProc(ref m);
  }
  </code></pre>
  
  <p>So what i need to do is : making the multimedia keys work even if the program is on the background and is not on top or focused , just like how winamp and Windows Media Player works.</p>
  
  <p>I searched a lot on the internet but most of them gives me a way similar to the one i am using.</p>
  
  <p>Thank you a lot for your help in advance.</p>