CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2000
    Posts
    45

    Little better explaination for Detection

    i no hwo to detect key board press combinations, but i dont no how to detect them anywhere on the desktop, i mean anywhere on the screen. please help


  2. #2
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: Little better explaination for Detection

    Use the GetAsyncKeyState() API Within a Timer Controls Timer Event, ie.
    private Declare Function GetAsyncKeyState Lib "user32" (byval vKey as Long) as Integer

    private Sub Form_Load()
    Timer1.Interval = 10
    End Sub

    private Sub Timer1_Timer()
    If GetAsyncKeyState(vbKeyControl) <> 0 And GetAsyncKeyState(vbKeyQ) <> 0 then
    Caption = "Pressing CTRL + Q"
    else
    Caption = ""
    End If
    End Sub



    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

  3. #3
    Join Date
    Feb 2000
    Location
    Kansas
    Posts
    49

    Re: Little better explaination for Detection

    Here's a pretty simple way of capturing a key event anywhere:


    Put this in a module:

    public Declare Function GetKeyState Lib "user32" (byval nVirtKey as Long) as Integer




    here's a loop that will constantly look for a keypress of 8 asynchronously:

    Do
    DoEvents
    i = GetKeyState(56)
    If i = 1 then
    MsgBox "8 was pressed"
    Exit Do
    End If

    Loop






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

Featured