Automating Internet Explorer using C/C++

旧城冷巷雨未停 提交于 2019-12-10 18:07:00

问题


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.


回答1:


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



回答2:


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...)



来源:https://stackoverflow.com/questions/9028894/automating-internet-explorer-using-c-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!