1

I am currently using the following function to detect special button presses (Play, Stop, Pause) on my MCE remote.

    Private Const WM_APPCOMMAND As Integer = &H319

Public Function WndProc(hwnd As IntPtr, msg As Integer, wParam As IntPtr, lParam As IntPtr, ByRef handled As Boolean) As IntPtr
    If msg = WM_APPCOMMAND Then
        Dim cmd As Integer = CInt(CUInt(lParam) >> 16 And Not &HF000)
        Select Case cmd
            Case 13 'Stop

        'Some Code

                Exit Select
            Case 47 'Pause

                 'Some Code

                Exit Select
            Case 46 'Play

                    'Some Code

                Exit Select
        End Select

        handled = True
    End If

    Return IntPtr.Zero
End Function

I would also like the functionality of using the colored buttons as well however when they are pressed, they do not seem to return anything for cmd.

Is there a way i can achieve this functionality?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Mattigins
  • 1,014
  • 9
  • 25

1 Answers1

0

These buttons can't be intercepted using the normal techniques (low level system hooks), but can be detected using RegisterRawInputDevices and looking for RAWINPUT Windows Messages. (RAWINPUT 91=Red, 92=Green, 93=Yellow, 94=Blue).

Sam Makin
  • 1,526
  • 8
  • 23
  • Would you mind giving me an example? i am having trouble finding documentation on RegisterRawInputDevices – Mattigins Aug 20 '14 at 11:27
  • http://msdn.microsoft.com/en-us/library/ms996387.aspx - c# but easily translatable. Furthers docs here - http://msdn.microsoft.com/en-us/library/ms645600.aspx – Sam Makin Aug 22 '14 at 09:40