Results 1 to 3 of 3

Thread: [RESOLVED] [VB6] - test if any key was clicked

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,964

    Resolved [RESOLVED] [VB6] - test if any key was clicked

    can i test if any key(in keyboard) was clicked?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [VB6] - test if any key was clicked

    Several methods

    1. Use GetKeyboardState API
    2. Use GetAsyncKeyState API
    3. Use a keyboard hook: SetWindowsHookEx API
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,964

    Re: [VB6] - test if any key was clicked

    Quote Originally Posted by LaVolpe View Post
    Several methods

    1. Use GetKeyboardState API
    2. Use GetAsyncKeyState API
    3. Use a keyboard hook: SetWindowsHookEx API
    thanks... the 1st resolved my problem
    and it's importanted put these function:
    Code:
    Public Function DetectSelectedKey(Key As Long) As Boolean
        If GetKeyState(Key) < 0 Then
            DetectSelectedKey = True
        Else
            DetectSelectedKey = False
        End If
    End Function
    the objective of these funcion it's for tell us if the key is pressed.
    and for see if any key(in these case we don't care what key was pressed) was pressd, use the keypress event. but the special keys(like arrow keys and the others special keys) don't work, then use the keydown event with 1 boolean variable for call it 1 time
    VB6 2D Sprite control

    To live is difficult, but we do it.

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