none
挂钩键盘 RRS feed

  • 问题

  • Option Explicit Public Declare Function CallNextHookEx Lib "user32" _ (ByVal hHook As Long, _ ByVal nCode As Long, _ ByVal wParam As Long, _ ByVal lParam As Long) As Long

    Public Declare Function UnhookWindowsHookEx Lib "user32" _ (ByVal hHook As Long) As Long

    Public Declare Function SetWindowsHookEx Lib "user32" _ Alias "SetWindowsHookExA" _ (ByVal idHook As Long, _ ByVal lpfn As Long, _ ByVal hmod As Long, _ ByVal dwThreadId As Long) As Long

    Public Const WH_MOUSE = 7

    Public Const HC_ACTION = 0

    Public Const WM_RBUTTONDOWN = &H204 Public hHook As Long

     Public Function MouseProc(ByVal nCode As Long, ByVal wParam As Long, _ ByVal lParam As Long) As Long

     If nCode >= 0 Then If nCode = HC_ACTION And wParam = WM_RBUTTONDOWN Then

    MsgBox "get WM_RBUTTONDOWN "

    End If

    End If

    MouseProc = CallNextHookEx(hHook, nCode, wParam, lParam) End Function

    End Function

    Option Explicit

    Private Sub UserControl_Initialize()
       hHook = SetWindowsHookEx(WH_MOUSE, _
                AddressOf MouseProc, 0&, App.ThreadID)
    End Sub
    你好!以上是对鼠标的挂钩,如何修改才能挂钩键盘中的A键,谢谢,我是初学者,请指教.

    2010年5月17日 11:37

答案