Skip navigation
Currently Being Moderated

Click a PDF Button from Visual Basic

Jun 28, 2010 6:37 AM

There is a button on a PDF form that I would like to click programmatically. I can get the name of the button's field by:

  

jso = pdDoc.GetJSObject

jso.getfield("Button Name")

 

When this button is clicked, it creates additional fields that need to be filled out. I've tried setting it's value to "1", "True", "Yes", etc. with no success.

 

How can I click this button or change it's properties for it to "click"? Do I need to call some kind of javascript and work in vb.net or something?

 

Thanks in advance for your help.

 

 

 
Replies
  • Currently Being Moderated
    Jun 28, 2010 7:00 AM   in reply to GVBman

    You can't "push a button" from javaScript.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 4, 2010 6:43 PM   in reply to GVBman

    Hi,

     

    If you can't get a button to be clicked through JavaScript as IroSenth says, then maybe you can approach it differently.

    Perhaps you can create those additional fields through a function that is called when the user has entered text into a field (or any user action)?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 9, 2010 11:39 AM   in reply to GVBman

    Hi,

     

    In VB / XP you can call Windows to simulate a click on the screen, however you need to pass the location of the click.

    Unless the PDF always open up the same way (say, 100% size), I don't see how you could provide consistantly the coordinates for the click.

    If it does open up the same way, then maybe you could go about finding the location via something like this:

     

    Get thewindow position using something like

     

    FindWindowEx and GetWindowPos and GetClientRect.

     

    Reference:


    http://www.xtremevbtalk.com/showthread.php?t=194129

    and

    http://allapi.mentalis.org/apilist/FindWindowEx.shtml

     

    Then assuming that the button position is always the same (I think it has to) then you could pinpoint the location on whatever customer's screen by going with percentages. If the button is 25% to the left of the window, and 25% down, you can do the arithmetic to find where to click.

     

    Reference (a good starting point):


    http://www.vbforums.com/showthread.php?t=345259

     

    and


    http://www.vb-helper.com/howto_move_click_mouse.html

     

    Hopes this helps

     

    Antoine

     

    ps: if it does help click to give me my first ten points good answer!

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 11, 2010 8:11 AM   in reply to GVBman

    It sounds like this is probably and xfa-based form which means that you really have no option but simulating the ui

     

    Leonard

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 11, 2010 8:13 AM   in reply to GVBman

    Buttons for xfa forms do not use native OS controls which is why you can't find it

     

    Leonard

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 11, 2010 1:46 PM   in reply to GVBman

    You could try to sniff its handle if it has one using spy++ or process monitor.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points