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

My C++ application is using a web browser (IE) control. I need to 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.

Related

How to launch IE from C++ code and be able to get html data after web page is changed

Here is my problem:
I am about to implement a method (C++),with an URL argument as parameter, what this method do is to launch the default browser of windows,and visit the url; this URL leads to an page, user of this program have to fill in some info in this page,and submit, then it jump to result page, and my method need to read and analyze this page data.
I know how to launch an browser like IE , but how to:
read page data to my program?
how my program know the page in browser is updated?
Maybe I should just write a web browser inside my program?
Looks like you want to do the IE browser automation. In which you want to launch the IE and try to fetch data from the web page.
With only C++ you can open the IE browser using shell and open the URL but you will not be able to fetch the data to your application.
I suggest you to check the documentation for Selenium Web driver.
I check and find that currently no any framework available for C++.
If you are available to use C# or JavaScript than it can help to solve your issue.
Reference:
Programming Languages & Frameworks
If you are available to use VBA than you can also refer link below for IE automation using VBA.
(1) Automate Internet Explorer (IE) Using VBA
(2) IE (Internet Explorer) Automation using Excel VBA
(3) VBA Internet Explorer Object

Openeing a youtube search via a link in an embedded IWebBrowser2 control fails

I have a simple IWebBrowser2 browser in my application like this one sample.
We use this browser control for a research in our application to search for address information. The user may click on a button to perform a selective search for given keywords in the address and the result is shown in this browser control.
For example we execute a YouTube search for
https://www.youtube.com/results?search_query=test+video
I can copy the link into a browser (Chrome, IE, Edge) and the search is executed.
But from within the embedded Control the search shows the following text:
Google Sorry...
We're sorry...
... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.
See Google Help for more information.
The help links are not useful, and the problem arises only to searches on Youtube from within the IWebBrowser2. No Captcha is shown. We use AV and Firewall software... so something from YouTube/Google don't like browsing from an IWebBrowser2.
Hint: If you want to use the sample code form CodeProject you should thet ES_AUTOHSCROLL for the URL edit control. Otherwise you will not be able to enter a long search URL.
Set the agent field of the http query header to emulate a known browser.

Navigate to the timeline (to the card with bundleId) from within an application

I have a Glass application that is activated by a voice command. The user requests a product and the request is then passed on to a node.js server, which handles the bulk logic of my application. When the node server is done, it builds some HTML templates that it passes on to the Mirror API, which then puts those cards into the timeline of the Glass app.
Now the problem I have is this:
When a user requests something from within the application, he just stays within that application but the cards from the Mirror API are put onto the timeline.
Is it possible to navigate the user from within the application to the timeline item that has just been inserted?
As I build the Mirror API timeline item, I know ahead of time what the bundleId will be on the timeline, so can I use that somehow to navigate to that item on the timeline?
I've had a look here on Stackoverflow, the Glass forums and the official documentation and couldn't see anything that would help.. Anybody here have any ideas?
Currently the only way for forcing a specific card to show in the timeline is by using a LiveCard (https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/timeline/LiveCard). Live cards will automatically be given focus when published and you can force the timeline to give your card focus after publishing by calling LiveCard.navigate().
So unfortunately unless you want to change some of the fundamentals of your app, this isn't going to be much help.
Though from the sounds of it, you may be able to use a LiveCard to show what is returned from your server. If you want to perform inserts via the mirror API, this could still be done in addition.

Using a web site button control via C/++

I use www.jango.com as PC music player and want to steer it remotly via my smartphone. I have a server program for controling the PC and an app as client.
I want to use the server program for example to press the play/pause or fast forward button in jango.com running inside the chrome webbrowser.
A simple way would be to simulate a windows mouse click at a specified position within the chrome window. But it would have the disadvantage that it would only work if the jango tab is active and will of course fail if the site changes it's layout and probably due to a lot other reasons.
So I'm thinking about generating kind of the same http request as the browser does if one clicks the button for real. Or somehow accessing the html elemnt
Please consider thatm while having a C/++ background, I lack any web/JS programming skills and would be in favor keeping it this way as much as possible.
Thank you for any suggestions!
The solution is to use an user script for the musik player web site which is able to trigger the buttons in question. Than websockets can be used to communicate between the user script and the c++ server program.

Help with design a facebook integration for my website.. App or Page?

I´m building a website to post my own videos using JW Player running my own ads as overlay.
www.planetsnowmobile.com
All my videos will be
Instead of register my own users, having my own forum etc etc I want to use facebook to interact with my visitors:
Individual discussions/comments on individual films instead of my own comment/forum-function
facebook-like-button for individual films (so induvidual like buttons for individual films)
Share induvidual films
Grab location from every unique visitor
Where do I start?
Do I need to create an application or should I use a Facebook "page"?
Maybe both?
I see that i can add an application to a "page" but what does that really do? How do I use that?
What would be the best way for me to do this?
I already have a Facebook "page" for my website and I just created an App as well.
Which one should I use?
Do I need both?
What is the difference?
I know that I can create a like button for a website address on http://developers.facebook.com/docs/reference/plugins/like/
But can I monitor that like button from example an application if I can connect them somehow?
Is that something I want to do?
My Facebook-page already have a user-base where my Facebook-application does not.. is my best option to delete my "page" and start all over with my "application"?
App is their encompassing term for any application that uses their API, this could be on Facebook or on your own personal website - these require an API key to make authenticated calls for users. Pages are FB's own in-Facebook content that users have created, like page for a business located at facebook.com/mybusiness. It sounds like you already have a website and want to add Facebook functionality to it, so you don't want to make another Page. You may not even need to create an App. Things like comment boxes and like buttons can be dropped in as stand-alone copy-and-paste widgets. You can track the like button by enabling FB insights for your website.
So like you noticed you can add a like button to your page using the social plugin from http://developers.facebook.com/docs/reference/plugins/like/ - similar to the like button you can add comment boxes with the plugin at http://developers.facebook.com/docs/reference/plugins/comments/
You can track the results from these plugins by adding your website to Facebook's analytics (Insights) at http://www.facebook.com/insights/
Most of these things are powered by the opengraph metadata in the headers of your website's pages. You can read up on what tags FB uses here http://developers.facebook.com/docs/opengraph/
Everything at http://developers.facebook.com/docs/plugins/ can be used without an application or page ID, and is very good about being responsive to the page they are hosted on: you can add a like button to your video view template without a defined URL in the like button's parameters, and it will automatically direct any likes to the url of the currently viewed video.
You could also direct a like button to point to your existing FB Page, in which case any likes collected from it would be added to the Page's total. Most companies that have a home-page like button do this, so their likes all accumulate to a single total for their business.
Hope that helps.