detecting multimedia keys
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: detecting multimedia keys

  1. #1
    Join Date
    Apr 2006
    Posts
    48

    detecting multimedia keys

    i need to find a way that i can detect the pressing of multimedia buttons on a keyboard (play, pause, next track, etc.) ive tried global keyboard hooks, those wont capture them... can anyone think of a way that this might be possible?

  2. #2
    Join Date
    Nov 2005
    Posts
    121

    Re: detecting multimedia keys

    Override the WndProc of your form and catch the WM_APPCOMMAND msg
    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 >> 16 & ~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 track");
    				break;
    			case 12:  // APPCOMMAND_MEDIA_PREVIOUSTRACK
    				MessageBox.Show("Previous track");
    				break;
    			default:
    				MessageBox.Show("cmd = " + cmd.ToString());
    				break;
    		}
    	}
    	base.WndProc(ref msg);
    }
    Last edited by bilm_ks; November 4th, 2006 at 05:52 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


HTML5 Development Center