I have a BHO working with IE9 on Win7(x86), made with VS2010.
What is does for now is quite simple:
- Listens to OnDocumentComplete events
- Copies the page source code into a wstring
- Searches for a substring in that wstring
Let's say that the substring is a HREF link.
Example: page.php?p=main/display&ID=12345
I'd like to navigate to that link the same way as if I clicked on it.
Ideally, I would have a function or method GoTo(wstring strNewPage) that would take the substring in parameter to make the browser navigate to the target page.
How would you implement that GoTo(wstring strNewPage) function? Any helpful information will be welcome too (classes & methods to use? examples?).
I'm not an advanced C++/ATL programmer, so the easier the better! :-)
In SetSite() you probably save a pointer to the provided site pointer. I guess it is of type IWebBrowser2. If not, do so.
When the time comes (I guess OnDocumentComplete), parse the page and see if you find your URL. If you do, use IWebBrowser2::Navigate2() to make the browser navigate to the specified URL.
Thanks Jose! Actually, I tried Navigate() and it works fine.
I noticed that I lose the "Referer" URL in the HTTP request, but I guess I can add a parameter for that.
Isn't there a function that "simulates" a click on a button, as well?
I would like that my BHO clicks on this kind of link that sends a POST request: