Results 1 to 6 of 6

Thread: Simulate keys pressed using API?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    3

    Question

    My only access to the window is through SendMessage. I am able to post any text, now I want to simulate keys...

    1) I can't send any ENTER key character to the edit control.
    2) Is it possible in any way to simluate i.e. ALT+R?

    Best Regards,
    Yves

  2. #2
    New Member
    Join Date
    Jul 2000
    Posts
    5
    1) to send ENTER to the edit control, you should just find the character for enter.......i think it might be chr(10) or maybe even chr(12)

    send this text to the edit control:
    "Line 1" & chr(10) & "Line 2"

    2) i'm assuming that by sending Alt-R, you are trying to get into a menu....to do that use the GetMenu and GetSubMenu functions

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    3
    1) I tryed both and even the vbNewline one, they don't work! Else I would not have asked...

    2) I am trying to run a Keyboard Express macro using ALT+R... Is there a way to simulate keys so that this would be possible?

    Best Regards,
    Yves

  4. #4
    Guest
    Try using the keybd_event or SendInput API.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    3

    Smile

    I am using SendMessage(hwnd, WM_CHAR, 13, 0) to send the Return key! Did not try but maybe I can simulate ALT+R the same way!

    Best Regards,
    Yves

  6. #6
    New Member
    Join Date
    Jul 2000
    Posts
    2
    USE THIS CODE

    Option Explicit
    Private Declare Sub keybd_event Lib "user32" _
    (ByVal bVk As Byte, _
    ByVal bScan As Byte, _
    ByVal dwFlags As Long, _
    ByVal dwExtraInfo As Long)
    Private Const VK_ENTER = &HD
    Private Const KEYEVENTF_KEYUP = &H1


    Private Sub Form_Load()
    Form1.Visible = False
    Dim VK_ACTION As Long
    VK_ACTION = &H52
    Call keybd_event(VK_ACTION, 0, 0, 0)
    Call keybd_event(VK_ALT, 0, 0, 0)
    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