Results 1 to 3 of 3

Thread: How do I use SendKeys if I know the hWnd

  1. #1

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245

    Post

    Let's say I have program that a user can enter some text into a textbox (txtDetails). And there is a seperate 3rd party program that has a form with a single text box on it.
    If I already know the 3rd party program's textbox hWnd (238), how do I properly paste txtDetails.Text in it's text box?

    Any help will be greatly appreciated and certainly rewarded with my undying graditude,
    Daniel Christie

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    Yuo can use the SendMessage API with the WM_SETTEXT Constant, ie.
    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_SETTEXT = &HC
    
    Private Sub Command1_Click()
        Dim sText As String
        sText = Text1
        Call SendMessage(lHwnd, WM_SETTEXT, Len(sText), ByVal sText)
    End Sub
    Where lHwnd is the WindowHandle of the Textbox in the 3rd Party App.


    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    ajyoung@pressenter.com


  3. #3

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245

    Post

    Thank you very, very much Aaron

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