Skip to main content

[archive] Webbrowser

  • April 24, 2009
  • 19 replies
  • 1 view

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks

19 replies

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
You would need to generate a "def" file for the "Microsoft HTML Object Library", first and include it in the SPECIAL-NAMES section, just like the WebBrowser. Then, you would do something like this:

01 PDisp-Handle HANDLE OF @IWebBrowser.
01 HTML-Doc-Handle HANDLE OF @HTMLDocument.


INQUIRE PDisp-Handle @Document IN HTML-Doc-Handle.
...

Or you could just do the following (if you don't need the pDisp handle):

INQUIRE WebBrowser1 @Document IN HTML-Doc-Handle.

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
I created the "def" file for the "Microsoft HTML Object Library", then I pasted it into the SPECIAL NAMES section. I'm using acubench so I right clicked on my program and viewed the cbl file and put it in that way, I don't know the proper way to add it. Unfortunately when I reparse my program acubench turfs the .def from the special names section :-)

Any thats besides the point point is acu doesn't seem to like the file I generated (I didn't get any errors). I do get all kinds of errors when I try to compile with the .def included tho. any ideas, maybe I need to manually massage the def file in some way after I generate it?

\\resource\\htmlobj.def, line 164749: identifier expected, Numeric literal found
\\resource\\htmlobj.def, line 164750: String literal expected, NAME found
\\resource\\htmlobj.def, line 164752: Native character specified twice, ordinal value = 74
\\resource\\htmlobj.def, line 164752: Native character specified twice, ordinal value = 113
\\resource\\htmlobj.def, line 164752: Native character specified twice, ordinal value = 74
\\resource\\htmlobj.def, line 164754: Native character specified twice, ordinal value = 74
\\resource\\htmlobj.def, line 164754: Native character specified twice, ordinal value = 102
\\resource\\htmlobj.def, line 164754: Native character specified twice, ordinal value = 111
\\resource\\htmlobj.def, line 164754: Native character specified twice, ordinal value = 117
\\resource\\htmlobj.def, line 164755: Number between 1 and 256 expected, -2147417611 found
\\resource\\htmlobj.def, line 164755: String literal expected, TYPE found
\\resource\\htmlobj.def, line 164755: Warning: '.' expected, TYPE found
\\resource\\htmlobj.def, line 164755: PROCEDURE expected, TYPE found
\\resource\\htmlobj.def, line 164755: DIVISION expected, TYPE found
\\resource\\htmlobj.def, line 164755: Warning: '.' expected, TYPE found
\\resource\\htmlobj.def, line 164755: identifier expected, TYPE found
\\resource\\htmlobj.def, line 164755: Missing PARA\\SECTION
\\resource\\htmlobj.def, line 164755: Can't recover, good bye!

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
I suspect this is a known bug, it relates to an enumerator having the same name as a class. If you search for HTMLInputImage, and find it as both enumerator and class, rename the enumerator to for instance: HTMLInputImageEnum and it should compile.
The ecn in question is 3875, fix is included in version 8.1.1

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
Dang! I forgot that I found that problem and worked around it just like Gisle suggested. Sorry I didn't mention it the first time - I forgot about it...

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
Thanks,

That seems to have done the trick. But I'm beginning to believe this might be a little beyond my scope, I messed around trying to give focus and set the data to some of the fields on the form and it just isn't working :-/

One question I do have is what is the proper way to add a def file to you program in the special name section from within an acubench project? everytime I regenerate it removes the def I put in there... I can't figure out where to manipulate some of the other sections of the code without actually editing the cbl file (which acubench just cleans up anyhow)...

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
I can't help as I don't use Acubench. Surely someone else knows? As to the code you are trying to write, if you could put a VB example of what you are trying to do along with the COBOL code you've tried, I'd be glad to look at it.

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
Thanks I appreciate your efforts. It's really pretty basic I have a website with 3 data entry fields (domain, username, password) and a submit button on it and I ultimately I would like to populate the 3 data fields and automatically click the submit button.

It's not my my website so I don't have any control over how it's displayed or built. But I am using the microsoft webbrowser control on my window, then I navigate to the site.

I found this vb code on the web that should allow me to change the focus to the first field then populate it and then populate next field etc. Then even click on the login button.

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
Post the def file you have generated and I will take a look at it.

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
Thanks,

That seems to have done the trick. But I'm beginning to believe this might be a little beyond my scope, I messed around trying to give focus and set the data to some of the fields on the form and it just isn't working :-/

One question I do have is what is the proper way to add a def file to you program in the special name section from within an acubench project? everytime I regenerate it removes the def I put in there... I can't figure out where to manipulate some of the other sections of the code without actually editing the cbl file (which acubench just cleans up anyhow)...


Do you allow acubench to generate all your code then?

We dont, however all you need to do is modify the tags in the .cbl file.
For example change this

       SPECIAL-NAMES.
      *{Bench}activex-def
       COPY "MyDef.Def".
           .
      *{Bench}end


To this

       SPECIAL-NAMES.
      *****{Bench}activex-def
       COPY "MyDef.Def".
           .
      *****{Bench}end


We used to have lookup programs which were initially from scratch in acubench and had to do this.
Acubench is then unable to removed your work.

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
Thanks,

That seems to have done the trick. But I'm beginning to believe this might be a little beyond my scope, I messed around trying to give focus and set the data to some of the fields on the form and it just isn't working :-/

One question I do have is what is the proper way to add a def file to you program in the special name section from within an acubench project? everytime I regenerate it removes the def I put in there... I can't figure out where to manipulate some of the other sections of the code without actually editing the cbl file (which acubench just cleans up anyhow)...


Do you allow acubench to generate all your code then?

We dont, however all you need to do is modify the tags in the .cbl file.
For example change this

       SPECIAL-NAMES.
      *{Bench}activex-def
       COPY "MyDef.Def".
           .
      *{Bench}end


To this

       SPECIAL-NAMES.
      *****{Bench}activex-def
       COPY "MyDef.Def".
           .
      *****{Bench}end


We used to have lookup programs which were initially from scratch in acubench and had to do this.
Acubench is then unable to remove your work.

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
I didn't expect so much help with this, thanks guys :-) it's more just to make the application easier to use (so users don't have to log into our application, then also the website). It's also for my own learning experience on for the windows API.

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
Do you allow acubench to generate all your code then?

We dont, however all you need to do is modify the tags in the .cbl file.
For example change this

We used to have lookup programs which were initially from scratch in acubench and had to do this.
Acubench is then unable to removed your work.


ya for this project we generate with acubench, what would be the benefits to not using acubench?

I thought of trying something like that, but I never got around to it, thanks for the tip.

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
Sorry, my question may be a little misleading.

We use acubench for all our development.
But we don't write programs from scratch in acubench.
We always have a "base" source file to work with in format of our choice and not its.

Hope that makes sence.
That way, we can easily add our own code etc etc.
And acubench can still have its tags to work with - then we're happy & it's happy.

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
Sorry, my question may be a little misleading.

We use acubench for all our development.
But we don't write programs from scratch in acubench.
We always have a "base" source file to work with in format of our choice and not its.

Hope that makes sence.
That way, we can easily add our own code etc etc.
And acubench can still have its tags to work with - then we're happy & it's happy.


That sounds like a really good idea, we are currently just beginning to migrate to using acubench. So any "new" programs we use acubench and are writing them to be GUI. we could prob use some training on how to use all the 'features' of acubench effectively, but I don't know if that is going to be on the horizon or not. Anyhow thanks for your input.

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
I have been able to create a clean build, however, it seems that these are dangerous waters, and I have no web page to try this one, so there is no guarantee it will work. But it should give you a start.

You should be particularly aware of the fact there are many variations of field types, in this particular example I have decided to trust I get a param and a button element, but I am sure best practise would be to check the element type before assigning it and then acting on it. How to determine this I don't know.

So, I guess the disclaimer will be that it compiles, but will it work, and will it work in a generic world? I have no idea at present.


       IDENTIFICATION               DIVISION.
       PROGRAM-ID.                  TEMPLATE.
       ENVIRONMENT                  DIVISION.
       CONFIGURATION                SECTION.
       SPECIAL-NAMES.
           copy "mshtml.def".
           copy "htmlobj.def".
           .
       WORKING-STORAGE SECTION.
       77  CNTL-FONT                USAGE HANDLE OF FONT SMALL-FONT.
       77  KEY-STATUS               IS SPECIAL-NAMES
           CRT STATUS               PIC 9(4) VALUE 0.
           88  EXIT-PRESSED         VALUE 27.
       01  EVENT-STATUS
           IS SPECIAL-NAMES EVENT STATUS.
           03  EVENT-TYPE           PIC X(4) COMP-X.
           03  EVENT-WINDOW-HANDLE  HANDLE OF WINDOW.
           03  EVENT-CONTROL-HANDLE HANDLE.
           03  EVENT-CONTROL-ID     PIC XX COMP-X.
           03  EVENT-DATA-1         SIGNED-SHORT.
           03  EVENT-DATA-2         SIGNED-LONG.
           03  EVENT-ACTION         PIC X COMP-X.
       01  hParamElement            HANDLE OF DispHTMLParamElement.
       01  hButtonElement           HANDLE OF DispHTMLButtonElement.
       01  hBrowser-disp            HANDLE OF IWebBrowser.
       01  hDocument-disp           HANDLE OF IHTMLDocument2.
       78  MSG-AX-EVENT             VALUE 16436.
       77  WS-NEW-URL               PIC X(1024) VALUE
                                    "[URL]www.yahoo.com[/URL]".
       SCREEN      SECTION.
       01  TEMPLATE-SCREEN.
           03 url-entry ENTRY-FIELD
              LINE                  02
              COL                   02
              SIZE                  40
              USING                 WS-NEW-URL.
           03 PUSH-BUTTON
              LINE                  02
              COL                   44
              TITLE                 "Action"
              EVENT PROCEDURE       Do-Navigate.
           03 hBrowser              WebBrowser
              LINE                  04
              COL                   02
              SIZE                  77
              LINES                 34
              EVENT PROCEDURE       Browser-Events.
           03 PUSH-BUTTON
              LINE                  39
              COL                   63
              SIZE                  14
              TITLE                 "E&xit"
              SELF-ACT
              EXCEPTION-VALUE       = 27.
       PROCEDURE DIVISION.
       MAIN-LOGIC.
           DISPLAY STANDARD         GRAPHICAL WINDOW
                   TITLE            "Template"
                   CONTROL          FONT CNTL-FONT
                   SIZE             80
                   LINES            40
                   BACKGROUND-LOW.
           PERFORM INITIALIZE-DATA.
           DISPLAY TEMPLATE-SCREEN.
           PERFORM WITH TEST AFTER  UNTIL EXIT-PRESSED
                   ACCEPT           TEMPLATE-SCREEN
           END-PERFORM.
           DESTROY TEMPLATE-SCREEN.
           STOP    RUN.
       INITIALIZE-DATA.
           INITIALIZE               KEY-STATUS.
           EXIT    PARAGRAPH.
       Do-Navigate.
           MODIFY  hBrowser         Navigate(WS-NEW-URL)
           EXIT    PARAGRAPH
           .
       Browser-Events.
           IF      EVENT-TYPE       = MSG-AX-EVENT
           AND     EVENT-DATA-2     = WebBrowserDocumentComplete
                   CALL             "C$GETEVENTDATA" USING
                                    EVENT-CONTROL-HANDLE
                                    hBrowser-disp
                                    WS-NEW-URL
                   INQUIRE          hBrowser-disp Document IN
                                    hDocument-disp
                   MODIFY           hDocument-disp
                                    @All::Item("field1")
                                    GIVING hParamElement
                   MODIFY           hDocument-disp
                                    @All::Item("button1")
                                    GIVING hButtonElement
                   MODIFY           hParamElement
                                    Focus()
                                    @Value = "my text value"
                   MODIFY           hButtonElement
                                    Focus()
                                    Click()
                   END-IF
           EXIT    PARAGRAPH
           .

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
wow you so didn't have to go to all the trouble! but your code is definately soild and I'm pretty sure it will work with some tweaking. It gets the handle to the webpage and the Document handle. Getting the individual field and button handles might be a little bit tricky, but I'm sure with some playing around I can get it to work.


Thanks again for all your help with this, it's a great learning experience for me :-)

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
So I finally had a chance to get back to working on this and I think the code Gisle supplied works very well. However I'm having a tough time trying to determine the "member names" when accessing the items on the webpage, maybe someone can help.

The following code dies with when the second line executes with "Member not found.":

MODIFY hDocument-disp @All::Item("domain") GIVING hParamElement.
MODIFY hParamElement Focus() @Value = "test data".


Here is a snippet of HTML from the website, how do I determine what the member names are for the 3 fields I want to populate?



JSCAPE Secure FTP Server - Web


Enter domain, username and password and click Login.




   
       
           
Domain:*
Username:*
Password:*

       

User Interface:
     HTML Java Applet



        LoginLogin



[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
Nevermind, after some fooling around I found I needed to define one of the handles differently.

01 hParamElement HANDLE OF DispHTMLParamElement.

Needed to be:
01 hParamElement HANDLE OF DispIHTMLInputTextElement.

And away it went! thanks again for all the help everyone :-)

[Migrated content. Thread originally posted on 23 April 2009]

Has anyone ever used the microsoft webbrowser control to automatically populate fields on a website and click the submit/login button?

So far as I can gather I need to do something like the following after I @navigate to my URL, but of course this is visual basic not cobol ;)

WebBrowser1.Document.All("field1").focus
WebBrowser1.Document.All("field1").Value = "my text value"
WebBrowser1.Document.All("button1").focus
WebBrowser1.Document.activeElement.Click


Anyone know how to convert this to cobol commands?

I tried:
MODIFY WebBrowser1, @Document::All("field1")::focus.

But I get a compile error of:
Interface definition '@IDISPATCH OF @SHDOCVW' not found

So I thought I needed to do something like:
INQUIRE WebBrowser1 @Document IN PDisp-handle.
but then how do I set the rest of the fields?

any ideas or direction would be much appreciated.
Thanks
Good work! :-)