Results 1 to 2 of 2

Thread: Need help wiv keypress

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2001
    Location
    Birmingham UK
    Posts
    49

    Cool Need help wiv keypress

    Is there an API call i can use to detect a keypress on my form when it isn't in focus. The idea of the keypress is in fact to bring it into focus. I want to bring the form to focus with something like (ctrl + shift + p)
    cheers.

  2. #2
    Addicted Member
    Join Date
    Nov 2000
    Location
    State of Confusion
    Posts
    133
    VB Code:
    1. 'In a module
    2. Public Declare Function GetAsyncKeyState Lib "user32" _
    3.     (ByVal vKey As Long) As Integer
    4.  
    5. 'In a timer control on your form
    6. Private Sub Timer1_Timer()
    7. Dim ControlState, ShiftState, PState As Integer
    8.     ControlState = GetAsyncKeyState(vbKeyControl)
    9.     ShiftState = GetAsyncKeyState(vbKeyShift)
    10.     PState = GetAsyncKeyState(vbKeyP)
    11.     If ControlState < 0 And ShiftState < 0 And PState < 0 Then
    12.         Me.WindowState = 0
    13.         MsgBox "Shift-Ctrl-P have been pressed!!  WooHoo!!"
    14.     End If
    15. End Sub

    You'll need a fairly low interval for it to work right, there may be an easier way, but I'm not sure what it would be....
    "Don't take life too seriously, you'll never get out alive"
    from Van Wilder

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