I want to write a small utility which can automate internet explorer using C++ (No MFC)
.
Some of the actions which i want to automate are :-
1. Opening a url
2. Clicking on a hyperlink in the browser instance
3. Setting the value of text boxes
4. Checking checkboxes, drop down menus etc.
I am an absolute beginner, and have no experience with COM
, however i am currently in the process of learning.
Can anyone guide me, like suggesting the resources and a breif outline of what i need to do to automate.
I will really appreciate it.
Thanks,
Ashish.
I strongly recommend the Microsoft Visual C++ compiler COM support.
Generally it works like this:
#import "c:\path\to\typelib.tlb"
#import "c:\path\to\library.dll"
#import "c:\path\to\program.exe"
This then makes it very easy to use Internet Explorer or any other COM object from C++.
See here for documentation:
- http://msdn.microsoft.com/en-us/library/h31ekh7e.aspx
Jeremy Thompson suggested the basic answer: use a WebBrowser control. That's far easier in C#, because it includes quite some of the boilerplate code you need. Even MFC contains some of that. Without that, you'll need to implement a proper ActiveX container. For someone not knowing COM at all, this is highly non-trivial. ActiveX is an advanced COM technique. There's a bit of sample code here
Once you've hosted it, things become fairly trivial in comparison. Opening a URL is just a single call: IWebBrowser2::Navigate(URL, flags...)