VB全局鼠标HOOK实现右键无效

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

Public Function LowLevelKeyboardProc(ByVal nCode As Long, 
    ByVal wParam As Long, ByVal lParam As Long) As Long
    Dim fEatKeystroke As Boolean

    If (nCode = HC_ACTION) Then
        If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Or 
           wParam = WM_KEYUP Or wParam = WM_SYSKEYUP Then
            CopyMemory P, ByVal lParam, Len(P)
            Select Case P.vKey
            Case VK_LWIN, VK_RWIN           '如果按了WIN键
                fEatKeystroke = True        '就吃了
            End Select
        End If
    End If
    If fEatKeystroke Then
        LowLevelKeyboardProc = -1
    Else
        LowLevelKeyboardProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
    End If
End Function

Public Function LowLevelMouseProc(ByVal nCode As Long, 
    ByVal wParam As Long, ByVal lParam As Long) As Long
    Dim fEatKeystroke As Boolean

    Select Case wParam                              '本例是让鼠标右键失效
        Case WM_RBUTTONDOWN, WM_RBUTTONUP
            fEatKeystroke = True
        Case WM_MOUSEMOVE
            Debug.Print "Mouse Move"
    End Select
    
    If fEatKeystroke Then
        LowLevelMouseProc = -1
    Else
        LowLevelMouseProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
    End If
End Function