Results 1 to 4 of 4

Thread: Recoginition of keypress thru API(Window API)

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    INDIA
    Posts
    7
    hi,
    is it possible to know whether any key is pressed in the
    form using window API. If yes then how???
    And after that is detected I want to call a function Which
    will do certain activity.
    Please tell me how to do it

    thx

    [email protected]

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    use GetAsyncKeyState and poll, but why not just use the Form_KeyPress Event with the KeyPreview property set to True?
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  3. #3
    Guest
    Here is an example of how to use the GetAsyncKeyState api:

    Code:
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    
    Private Sub Timer1_Timer()    
    Dim iKey As Integer    
    For iKey = 0 To 255       
    If GetAsyncKeyState(iKey) Then Caption = "KeyCode: " & iKey & " was pressed."   
    Next 
    End Sub

  4. #4
    Guest
    Numbers 2 and below represent a NullCharacter, left mouse and right mouse respectively. If you don't want to capture them, simply start from 3.

    Code:
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    
    Private Sub Timer1_Timer()
        Dim iKey As Integer
        For iKey = 3 To 255
            If GetAsyncKeyState(iKey) Then Caption = "KeyCode: " & iKey & " was pressed."
        Next
    End Sub

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