Results 1 to 5 of 5

Thread: SendKeys

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    59

    Cool

    I am coding a program using alot of API functions. At the end of the program i want to send the keys "{enter}" but everytime i do that: sendkeys "{enter}" the program freezes. Does anybody know how i can use an API to send the "{enter}" key stroke, instead of using the Sendkeys Utilitie?

  2. #2
    Guest
    Code:
    Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As String) As Long
    Private Const WM_CHAR = &H102
    
    Private Sub Command1_Click
    Call SendMessageByString(thehwndoftheprogram, WM_CHAR, 0&, Chr$(13))
    End Sub

    havent tried that, but it should work.

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    59
    No, it did not work. Nothing happens. No error no nothing.

  4. #4
    Guest
    Try this:
    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
    Const WM_CHAR = &H102
    
    Private Sub Command1_Click()
        Call SendMessage(Me.hwnd, WM_CHAR, vbKeyReturn, 0)
    End Sub

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    59
    Thank you Megatron. Tha code worked well.

    Thanx

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