One thing I'm required to do alot in my work is navigate a web page using vb6 and fill in values on web controls, hit search buttons, etc. For the most part on standard controls I know how to do this, simply by doing something like:
Set anElem = htmlDoc.getElementById("ct
anElem.value = Format(whichDay, "mm/dd/yyyy")
In most cases this works fine.. however, in cases like these datetimepicker controls you can set the value but when you click the search button it instantly reverts back to the original value. The only way to make it stick is to trigger events on the control such as actually pasting in a value or typing it in. As a matter of fact, in the past I've overcome this barrier by using SendKeys to the control, after setting the focus, but this is a clunky solution and I always have to check the value afterwards to see if sendkeys even put it in right. Furthermore, this takes the control of the screen so the user can't run anything else while my program is running and filling out web pages.
I need a better way so bad.
Since setting the value doesn't work I've been thinking maybe I could actually call the "paste" event on the control or something like that and pass it the value I want pasted in. Is this doable?
I'm even willing to use the keydown event and just send it the keys I want one at a time if necessary.
Go to this page if you want to see an EXAMPLE of the same kind of calendar control I'm talking about:
Then click on the "Document Type" link and you'll see that there is a Start Date control and an End Date control.
I like to use google chrome and inspect the element to see all the events on the control and all the properties and everything you could imagine. Chrome reveals that the paste event, and the keydown, keyup and keypress events all have event listeners attached to them.
How do I call these events from my code, and pass along values with them?
This is something I've been wishing I could learn for a very long time and any help on this would be greatly appreciated!
Thanks so much! ~Jeffrey