We help IT Professionals succeed at work.
Get Started

How can I capture a 3 key press combination

Silvertree asked
Last Modified: 2012-05-05
I need to be able to capture Ctl-Alt-F10 for an app that i am writing. now i can get Ctl-Alt, but not the F10 Here is my code:

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)
            If (VK_F10) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0) And ((p.flags And LLKHF_ALTDOWN) <> 0) Then
                    <Do Stuff>
                    fEatKeystroke = False
                End If
                fEatKeystroke = _
                ((p.vkCode = VK_TAB) And ((p.flags And LLKHF_ALTDOWN) <> 0)) Or _
                ((p.vkCode = VK_ESCAPE) And ((p.flags And LLKHF_ALTDOWN) <> 0)) Or _
                ((p.vkCode = VK_ESCAPE) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0)) Or _
                (p.vkCode = VK_RWIN) Or _
                (p.vkCode = VK_LWIN) Or _
                (p.vkCode = LLKHF_ALTDOWN) Or _
                (p.vkCode = VK_ESCAPE) Or _
                (p.vkCode = VK_CONTROL And GetKeyState(VK_CONTROL))
            End If
        End If
    End If

    If fEatKeystroke Then
        LowLevelKeyboardProc = -1
        LowLevelKeyboardProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
    End If
End Function

The line "If (VK_F10) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0) And ((p.flags And LLKHF_ALTDOWN) <> 0) Then" does not work properly all the time.

Can anyone help?
Watch Question
This problem has been solved!
Unlock 2 Answers and 5 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE