Basic Univers
; Capte les événements générés par les touches d'un clavier multimédia (play/pause/next)...

Enumeration
  #APPCOMMAND_BROWSER_BACKWARD        =   1
  #APPCOMMAND_BROWSER_FORWARD
  #APPCOMMAND_BROWSER_REFRESH
  #APPCOMMAND_BROWSER_STOP
  #APPCOMMAND_BROWSER_SEARCH
  #APPCOMMAND_BROWSER_FAVORITES
  #APPCOMMAND_BROWSER_HOME
  #APPCOMMAND_VOLUME_MUTE
  #APPCOMMAND_VOLUME_DOWN
  #APPCOMMAND_VOLUME_UP
  #APPCOMMAND_MEDIA_NEXTTRACK
  #APPCOMMAND_MEDIA_PREVIOUSTRACK
  #APPCOMMAND_MEDIA_STOP
  #APPCOMMAND_MEDIA_PLAY_PAUSE
  #APPCOMMAND_LAUNCH_MAIL
  #APPCOMMAND_LAUNCH_MEDIA_SELECT
  #APPCOMMAND_LAUNCH_APP1
  #APPCOMMAND_LAUNCH_APP2
  #APPCOMMAND_BASS_DOWN
  #APPCOMMAND_BASS_BOOST
  #APPCOMMAND_BASS_UP
  #APPCOMMAND_TREBLE_DOWN
  #APPCOMMAND_TREBLE_UP
 
;#if(_WIN32_WINNT >= 0x0501)
  #APPCOMMAND_MICROPHONE_VOLUME_MUTE
  #APPCOMMAND_MICROPHONE_VOLUME_DOWN
  #APPCOMMAND_MICROPHONE_VOLUME_UP
  #APPCOMMAND_HELP
  #APPCOMMAND_FIND
  #APPCOMMAND_NEW
  #APPCOMMAND_OPEN
  #APPCOMMAND_CLOSE
  #APPCOMMAND_SAVE
  #APPCOMMAND_PRINT
  #APPCOMMAND_UNDO
  #APPCOMMAND_REDO
  #APPCOMMAND_COPY
  #APPCOMMAND_CUT
  #APPCOMMAND_PASTE
  #APPCOMMAND_REPLY_TO_MAIL
  #APPCOMMAND_FORWARD_MAIL
  #APPCOMMAND_SEND_MAIL
  #APPCOMMAND_SPELL_CHECK
  #APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE
  #APPCOMMAND_MIC_ON_OFF_TOGGLE
  #APPCOMMAND_CORRECTION_LIST
  #APPCOMMAND_MEDIA_PLAY
  #APPCOMMAND_MEDIA_PAUSE
  #APPCOMMAND_MEDIA_RECORD
  #APPCOMMAND_MEDIA_FAST_FORWARD
  #APPCOMMAND_MEDIA_REWIND
  #APPCOMMAND_MEDIA_CHANNEL_UP
  #APPCOMMAND_MEDIA_CHANNEL_DOWN
EndEnumeration

Macro LOWORD(Value)
  Value & $FFFF
EndMacro

Macro HIWORD(Value)
  Value >> 16) & $FFFF
EndMacro

#FAPPCOMMAND_MASK  = $F000
Macro GET_APPCOMMAND_LPARAM(lParam)
  HIWORD(lParam) & ~#FAPPCOMMAND_MASK
EndMacro

Procedure WndProc(WindowID, message, wParam, lParam)
Protected result.l, cmd.l

  result = #PB_ProcessPureBasicEvents
 
  If message = #WM_APPCOMMAND
    cmd = GET_APPCOMMAND_LPARAM(lParam)
    Debug "cmd = " + Str(cmd)
  EndIf
 
  ProcedureReturn Result
EndProcedure

If OpenWindow(0, 0, 0, 320, 240, "Multimedia Keyboard Extension")
  SetWindowCallback(@WndProc())
  Repeat : event = WaitWindowEvent() : Until event = #PB_Event_CloseWindow
EndIf