开发者

Web Browser control in C++: Detecting mouse click on specific button

开发者 https://www.devze.com 2023-04-05 05:35 出处:网络
My C++ application is using a web browser (IE) control. I need to开发者_如何学Go detect when the user clicks a button on a specific web page (using the element ID of that button).

My C++ application is using a web browser (IE) control. I need to开发者_如何学Go detect when the user clicks a button on a specific web page (using the element ID of that button). How can I do this? I already have an event sink implemented, but I do not know how to catch mouse click on DOM elements.


The event you are looking for is probably related to:

onclick event

But whether this is accessible from the MS IE API from C++ via EventSinks, I don't know.

Other Round-About Way to Get Click Information to Your C++ Code

I am not an expert on it, but companies like UserZoom, analyze the information by inserting Javascript via a plug-in to the web browser. Here is a quote from their FAQ of how they collect the click-streams:

UserZoom FAQ

Data Collection & Tracking

What type of information is UserZoom capable of tracking during the tasks?

With the plug-in version or non plug-in with JavaScript tracking code, UserZoom can track participants’ navigation paths as well as where participants have clicked on pages throughout the tasks (heatmaps). With the non plug-in version, navigation paths and participant clicks cannot be captured.

Now with this knowledge, go find a javascript library that can get the clicks and the document object model info.

Google Search: "how to get where the user clicked element in javascript"

How to get the target element when clicked?

StackOverflow: JavaScript: Get clicked element

Then you need to insert that bit of javascript into the webpages into the browser the user is using.

Adding Javascript with an add-on/extension/plugin in Firefox and Chrome is relatively easy, I've heard, but for IE, I think you have your work cut out for you to create the add-on in IE. After much searching I found this:

Inject HTML and JavaScript into an existing page with BHO using MS Visual Studio 2010 and C#

And lastly, get that information out of the javascript and into your code using JSON or AJAX and setting up a local webserver to receive it:

Google Search: receive ajax c++

Jquery Ajax Calling Functions

AJAX and the C++ Programmer

Hopefully that information gives you a starting point. Good luck.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号