Results 1 to 4 of 4

Thread: Keyboard clicks

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Posts
    6

    Question

    Hay,

    I'm wondering how to make Wndows 98 think that somebody has pressed a key on the keyboard with VB6. I've figured out how to move and click the mouse, now i just need to know how to simulate typing on the keyboard.

    Thx,

    Fried Chicken
    _______________
    Don't bother
    me. I'm eating.

  2. #2
    Guest
    Code:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Const WM_KEYDOWN = &H100
    
    Private Sub Command1
        'Press the "A" key
        SendMessage MyHwnd, WM_KEYDOWN, vbKeyA, 0
    End Sub

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    You could try SendKeys or try the KeyB_Event:

    Code:
    'SendKeys
    Private Sub Form_Activate()
    SendKeys "HELLO", True
    End Sub
    Code:
    'Keybd_Event
    Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Const KEYEVENTF_KEYUP = &H2
    
    Private Sub Form_Activate()
    TypeChar vbKeyH
    TypeChar vbKeyE
    TypeChar vbKeyL
    TypeChar vbKeyL
    TypeChar vbKeyO
    End Sub
    Private Sub TypeChar(Char As Long)
        keybd_event Char, 0, 0, 0
        keybd_event Char, 0, KEYEVENTF_KEYUP, 0
    End Sub
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Posts
    6
    Thanks guys

    _____________
    Fried Chicken
    Don't bother
    me! I'm gaining
    weight! :| DUHHH

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