Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3776
  • Last Modified:

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.
0
josgood
Asked:
josgood
  • 2
  • 2
1 Solution
 
Bob LearnedCommented:
Would it be possible to use the WebBrowser control?

Bob
0
 
josgoodAuthor Commented:
Bob,

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.

Joe
0
 
Bob LearnedCommented:
Joe,

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

Bob
0
 
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!
0
 
modus_operandiCommented:
Closed, 500 points refunded.
modus_operandi
Community Support Moderator
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now