Results 1 to 6 of 6

Thread: SendMessage API Sending Enter Key How? Help!

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Posts
    127

    SendMessage API Sending Enter Key How? Help!

    Ok How do I do this, I am trying to send the enter key to a combo box after I change the text in it.

    I have an old legacy app i am trying to convert over and well i am trying to automate the data entry process and I am almost done but I am having a problem with one part. Also this is a vb application controlling another Application which is why I am doing some crazy crap here

    Basically I have a combo box that allows me to enter text into it hence creating another option however before it becomes a valid option you must hit the enter key

    Here is the current code I am using for this in a module and it works as far as entering in the text I just cant get it to hit the enter key

    Code:
    Public Const WM_SETTEXT = &HC
    Public Const WM_CHAR = &H102
    Public Const ENTER_KEY = 13
    
    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Public Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
    Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Public Declare Function SendMessageLong& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
    
    
    Public Sub EnterCombo(txtToEnter As String)
    Dim Edit As Long
    Dim ComboBox As Long
    Dim MyProg As Long
    
    MyProg = FindWindow("Flex Account", vbNullString)
    ComboBox = FindWindowEx(MyProg, 0, "ComboBox", vbNullString)
    Edit = FindWindowEx(ComboBox, 0, "Edit", vbNullString)
    
    Call SendMessageByString(Edit, WM_SETTEXT, 0&, txtToEnter)
    Call SendMessageLong(Edit, WM_CHAR, ENTER_KEY, 0&)
    End Sub
    Last edited by BOUND4DOOM; Feb 23rd, 2002 at 11:45 PM.
    The secret to creativity is knowing how to hide your sources.
    -- Albert Einstein

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