Results 1 to 3 of 3

Thread: Using API instead of VB's Sendkey func

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Location
    Ontario Canada
    Posts
    1

    Exclamation Using API instead of VB's Sendkey func

    I was wondering if anybody could help or explain how I would go about sending keys to a game using API

    I can send keys right now using the Sendkey command in Visual Basic, although I cannot send keys if the game client is maximized

  2. #2
    jim mcnamara
    Guest
    From allapi.net - sends a keystroke to the gotfocus window. You have to send both keydown & keyup.....
    Code:
    
    Const VK_H = 72
    Const VK_E = 69
    Const VK_L = 76
    Const VK_O = 79
    Const KEYEVENTF_EXTENDEDKEY = &H1
    Const KEYEVENTF_KEYUP = &H2
    Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Private Sub Form_KeyPress(KeyAscii As Integer)
        'Print the key on the form
        Me.Print Chr$(KeyAscii);
    End Sub
    Private Sub Form_Paint()
        'KPD-Team 2000
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        'Clear the form
        Me.Cls
        keybd_event VK_H, 0, 0, 0   ' press H
        keybd_event VK_H, 0, KEYEVENTF_KEYUP, 0   ' release H
        keybd_event VK_E, 0, 0, 0  ' press E
        keybd_event VK_E, 0, KEYEVENTF_KEYUP, 0  ' release E
        keybd_event VK_L, 0, 0, 0  ' press L
        keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0  ' release L
        keybd_event VK_L, 0, 0, 0  ' press L
        keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0  ' release L
        keybd_event VK_O, 0, 0, 0  ' press O
        keybd_event VK_O, 0, KEYEVENTF_KEYUP, 0  ' release O
    End Sub

  3. #3
    Megatron
    Guest
    The virtual key codes are already defined in VB as vbKeyH, vbKeyE, vbKeyL etc., hence you don't need to declare additional constants.

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