Results 1 to 2 of 2

Thread: How to use sendmessage to send text to browser

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    3

    How to use sendmessage to send text to browser

    I'm using vb6. How do I use sendmessage to send text to the microsoft internet controls component that's in my main form. I need to send text to a textbox that's in a webpage in the browser. Everything works flawlessly with sendkeys, however I really want to free up my computer to do other things. The webpage is also in XML.

    Right now I can set the text of a textbox.

    To prevent garbage text i used a modified sendmessage (change ByVal lParam As Any to ByVal lParam As String)

    Code:
    Private 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
    Code:
    Call SendMessageByString(Frmmain.Text2.hwnd, WM_SETTEXT, 0&, "Hello")
    The above code works

    What I am trying to do is
    Code:
    Call SendMessageByString(Frmmain.browser.hwnd, WM_SETTEXT, 0&, "Hello")
    The above code returns both an automation error and an unknown error in a single msgbox. I've tried wm_keydown / wm_keyup and it doesn't work for the textbox (I think I'm doing something wrong). Remember that the webpage is in XML. I think the problem is that a specific object like a textbox in the webpage needs to be pointed out, otherwise it sends text to the browser component which does nothing. Just like trying to send text to a picturebox does nothing. I know there's a command out there where you can enter in text to a certain object or element in the webpage but I forgot how to do it.

    Code:
    Frmmain.Browser.Document.All("Id of html element").SetAttribute("Value", "new value")
    or
    Code:
    frmmain.Browser.Document.GetElementById("username").SetAttribute("Value", frmmain.txtuser.Text)
    The above code seems to be in vb.net, is browser.document.all going to solve my problem?
    Last edited by nesu; Mar 30th, 2009 at 02:28 AM.

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