我有此代碼(鍵盤鉤子),用於註冊該鍵盤的所有鍵,並且它播放聲音:鉤一鍵不工作完全
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
末級
當窗體是最大限度地發揮它的作用,但是當最小化它不起作用。 使用此代碼sound1與所有按鍵一起播放,但我希望sound1使用按鍵A和聲音2使用按鍵B播放.... 我該怎麼做?非常感謝您
一個
timer
我要回答的評論,因爲我之前已經回答了這個問題一個受信任的代碼。有一個專門用於此目的的codeplex庫。它可以在這裏下載http://globalmousekeyhook.codeplex.com –謝謝馬克,這是非常有用的。 – Frankcoding