Use mshtml.HTMLDocument to control a browser window

I have an mshtml.HTMLDocument that I fetched from an Internet Server_Explorer window, as in
         mshtml.HTMLDocument document = null;
         uint WM_HTML_GETOBJECT = RegisterWindowMessage("WM_HTML_GETOBJECT");
         SendMessageTimeout(hWnd, WM_HTML_GETOBJECT, IntPtr.Zero, IntPtr.Zero,                                                               SendMessageTimeoutFlags.SMTO_NOTIMEOUTIFNOTHUNG, 1000, out lngRes);
         document = (mshtml.HTMLDocument) ObjectFromLresult(
                                 lngRes, typeof(mshtml.HTMLDocument).GUID, IntPtr.Zero);

I ordinarily fill in the form by hand and click the Go button.  I want to change that to an automated process, which is why I have this question.

The HTML in the document contains
      <INPUT class=oFF size=15 value=ABC name=p>
      <INPUT class=oFF type=submit value=Go>
The INPUT field named p contains the value I would like to send to the host and the INPUT field named Go is the button I would like to push.

I'm assuming that mshtml.HTMLDocument will allow me to do this.

Am I right?
If I'm right, how do I do that?
If I'm wrong, how else should I approach the problem?

Thank you.
LVL 13
Who is Participating?
josgoodAuthor Commented:

Thank you for answering my question.  You were the only one to do so.  The WebBrowser control is a definite possibility, but I haven't looked into it.

I looked into mshtml and have worked out an answer.

mshtml.HTMLDocument provides an Index method that requires both an object name and an index into the collection of document attributes.  By iterating over the attribute collection, I can find the index of the attribute I'm interested in.  I already know the object name.  So then Index(object-name,index) returns an object that I can cast to the necessary type.

There has to be a better way.  The iteration should not be necessary and I am uncomfortable with the cast .  But it works, and that's OK for now.

Bob LearnedCommented:
Would it be possible to use the WebBrowser control?

Bob LearnedCommented:

The only thing that matters is whether you have something that works for you.

josgoodAuthor Commented:
I agree.  Perfection can wait, I'm busy.  <G>

I'll ask community support to close out this question.

Have a great day!
Closed, 500 points refunded.
Community Support Moderator
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.