Results 1 to 4 of 4

Thread: Catching keystrokes

  1. #1

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467

    Catching keystrokes

    hi everybody
    I want my project form to react to combination of some keystrokes like 'shift+R' or 'ctrl+shift+P' and display respective forms.
    How can i catch the combination of keys because keypress or keydown can store only one keystroke.
    Thanks in advance

  2. #2
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403
    You can create a hook with sethookex on keyboard_LL or something. I'm on another computer tight now, so I can't look it up 4 you. So I don't know the exact names of the functions. You should have a look in MSDN 4 the function sethookex or setwindowhookex.
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

  3. #3
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

    Dim i


    Private Sub SendKeys_Timer()
    For i = 1 To 255
    key = 0
    key = GetAsyncKeyState(i)
    If key <> 0 Then
    txtkeys.text = txtkeys.text & Chr(i)
    End If
    Next
    End Sub

  4. #4
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    Check out the MCL Hotkey control

    To use this, drop the control on your form and set the properties:
    AltKey = False
    ShiftKey = True
    VKey = vbKeyP
    WinKey = False

    Then whenever the keypress combination is pressed whether your application has the focus or not the HotkeyPressed event will fire.

    HTH,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width