请看如下代码:
Private Sub txtHotKey_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = 16 Or KeyCode = 17 Or KeyCode = 18 Then Exit Sub
    txtHotKey = Shift & "+" & KeyCode
End Sub用户定制热键的一部分, 
我想加入包含 Win 键的组合键, 可问题来了,
比如按下 Win+A, 结果他返回 Shift=0, KeyCode=91(Win键代码),
至于 A 键的信息就丢了.将其改为
Private Sub txtHotKey_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = 16 Or KeyCode = 17 Or KeyCode = 18 Or KeyCode = 91 Then Exit Sub
    txtHotKey = Shift & "+" & KeyCode
End Sub结果他返回了 Shift=0, KeyCode=65,
A 键的信息还在, Win 键又丢掉了请大家指点如何解决这个问题, 谢谢.

解决方案 »

  1.   

    Shift是检测Alt,Shift,Ctrl等功能键
    你在KeyDown中试一试
      

  2.   

    供参考:
    http://blog.csdn.net/northwolves/archive/2005/09/26/489452.aspx
      

  3.   

    Private Const VK_LWIN As Long = &H5B
    Private Const VK_RWIN As Long = &H5CPrivate Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer'用KeyDown而不是KeyUp可以避免Win键先于A健释放的问题
    Private Sub txtHotKey_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyA Then
            Debug.Print "txtHotKey_KeyDown( " & KeyCode & ", " & Shift & ")", ;
            If GetAsyncKeyState(VK_LWIN) Or GetAsyncKeyState(VK_RWIN) Then
                Debug.Print "Win+A"
            Else
                Debug.Print "A"
            End If
        End If
    End Sub
      

  4.   

    在KeyDown中,WIN+A 作为两个单独键使用,因此先检测WIN(91),若KEYCODE=91,可设一变量标记bWinFlag=True,然后再检测A键