I have this code(keyboard hook) for register all the keys of the keyboard,and it plays a sound:
Public Class Form1
Dim iresult As Long
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
Private WithEvents kbHook As New KeyboardHook
Private Sub kbHook_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles kbHook.KeyDown
mciExecute("Play C:\sonido3.wav")
End Sub
Private Sub kbHook_KeyUp(ByVal Key As System.Windows.Forms.Keys) Handles kbHook.KeyUp
End Sub
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyData
Case Keys.A
mciExecute("Play C:\sonido1.wav")
Case Keys.B
mciExecute("Play C:\sonido2.wav")
End Select
End Sub
End Class
When the form is maximized it works well,but when is minimized it doesn't work. With this code the sound1 is played with all the keys,but I want that the sound1 is played with the key A,sound 2 with key B.... How can I do this?Thank you very much