W$KEYBUF and Web Browsers...

I am attempting to open a website using a Browser component (in AcuBench)...once the website opens I want to auto-populate the fields where the cursor is sitting.  I would think the W$KEYBUF command would do this but I am having no luck. 

Does anyone have any clues they might give me on how to auto-populate key strokes on a Browser window?

Thanks.

  • Can you provide a bit more detail about what you are trying to do .. the browser control in of itself does acce[pt key strokes. Typically you use an entry field to allow somwone to type in a url in order to then have the browser control navigate to that web site ... like the example browser.cbl  ... in the sample directory C:\Program Files (x86)\Micro Focus\Acucbl912\AcuGT\sample

  • I am attempting to open a website and then have a user & password auto-populate.  We have users that must hit verification websites and require logins each time.  We are looking for ways to simplify this for them.  We have the Browser already getting to the sites (this is not problem) but would like to auto populate the name and password fields on the websites for them.

  • Would it not be easier to simply log the user in on a particular website?  On the assumption that a web site is simply submitting an HTML form that contain the user name and password, most web sites will accept a URL that includes the user name and password as query parameters.

    Can you be more specific?

  • Sorry I can't give links or print screens of the official sites....they are secure medical eligibility websites that do not accept HTML forms or parameters in their addresses.  You are given a page that has 2 entry fields (user and password) with 2 buttons (Submit and Clear).  

    We have also approached them about APIs but they do not have any at this time.

    Since my original question was posted I have actually gotten the W$KEYBUF to fill in the wanted fields at times but it is not consistent (I think it is a timing issue of when the page finishes loading in the browser).  Now my issue is clicking a "submit" button.   The websites do not accept the ENTER key as a way to select a button...you must click with a mouse.  

  • Is there JavaScript attached to the Submit button?

  • A possibility that might give you more control would be to 'wrap' the login page in another web page of your own, using an inline frame.  I am not a JavaScript expert, but it would seem to me that this might make what you are trying to achieve possible, including causing a click event on the correct button.

    Another possibility would be to use RMnet (available in most recent versions of ACUCOBOL).  No matter what technology is being used, at some point a request payload is being transmitted to the server and a response is returned, probably along with a session cookie.  RMnet is a COBOL-callable wrapper around the http and https capability of libcurl, and can manipulate the payloads more precisely.  I would consider this a choice to be considered if the browser control/JavaScript thing just won't play.

  • Use the DocumentComplete Event for the Browser control. And see the following code for populating some sample fields and clicking a button on the website.

    NOTE: This is using the Microsoft OCX:Web Broswser NOT the Acu Browser.

           01  hInputElement       HANDLE OF @DispIHTMLInputTextElement.
           01  hButtonElement      HANDLE OF @DispHTMLButtonElement.
           01  hBrowser-disp       HANDLE OF IWebBrowser.
           01  hDocument-disp      HANDLE OF IHTMLDocument2. 

    CALL "C$GETEVENTDATA" USING EVENT-CONTROL-HANDLE
                                           hBrowser-disp
                                           WS-URL.

    INITIALIZE hDocument-disp.

    INQUIRE hBrowser-disp Document IN hDocument-disp.

               IF  hDocument-disp NOT = ZEROS
                  INSPECT WS-ADDRESS REPLACING TRAILING " " BY LOW-VALUES
                  INSPECT WS-USERNAME REPLACING TRAILING " " BY LOW-VALUES
                  INSPECT WS-PASSWORD REPLACING TRAILING " " BY LOW-VALUES
                  MODIFY hDocument-disp @All::Item("domain")
                              GIVING hInputElement
                  MODIFY hInputElement Focus()
                  MODIFY hInputElement @Value = WS-ADDRESS
                  MODIFY hDocument-disp @All::Item("username")
                              GIVING hInputElement
                  MODIFY hInputElement @Focus()
                  MODIFY hInputElement @Value = WS-USERNAME
                  MODIFY hDocument-disp @All::Item("password")
                              GIVING hInputElement
                  MODIFY hInputElement Focus() @Value = WS-PASSWORD
                  MODIFY hDocument-disp @All::Item("Login")
                              GIVING hButtonElement
                  MODIFY hButtonElement Focus()
                  MODIFY hButtonElement Click()
               END-IF.