0

I am creating an application to open a website in a c# webbrowser control, and track the elements being clicked from that website. So I chose to make a c# application with a webbrowser and on click within the website the elements being clicked are to be logged. I'm having a problem on finding the most efficient way to handle mouse click events of the website within the webbrowser.

3 methods which I found out:

  • Applying a transparent panel in front of the webbrowser so that when a click is done the mouse coordinates are used to get the element inside the webbrowser and further on log it.
  • Applying the logging system on document loading complete.
  • Applying a timer with a very low interval to detect any clicks done within the webbrowser control.

I am using the first method but I'm having a bit of problems on hiding the transparent panel when a click is done and replicating the click, but I believe a I can find a solution to this. I chose not to use the second method because when the webbrowser is changing website the trigger event doesn't work correctly. And the 3rd method will require alot of unneeded resources to log the clicks.

Is there any suggestions on how to make the system more efficient?

sgrech
  • 35
  • 8
  • The transparent panel will also make your life complicated if the Web Page scrolls about. What about the OnNavigate event? – simon at rcl Jan 24 '14 at 14:35
  • Yes, transparent has those drawbacks indeed.. You would choose the timer method? – sgrech Jan 24 '14 at 14:38
  • I'm not sure. What are you actually trying to do? Why do you need to know that a button has been clicked? – simon at rcl Jan 24 '14 at 14:39
  • I'm just doing a logging system that lists down the elements within the website being clicked, this can further on be used to make an analysis on which elements are most used or replicate the elements sequence clicked. – sgrech Jan 24 '14 at 14:43
  • Is this WebSite your own? Can you change it? – simon at rcl Jan 24 '14 at 14:46
  • The website within the webbrowser can be any website. It is not always the same website. It can be changed on the user request. – sgrech Jan 24 '14 at 14:47
  • If it was for just one website, hotspots could be added in order to find out which one is being clicked or so. – sgrech Jan 24 '14 at 14:48
  • I think I'd try not to do it! However, the transparent panel might be possible. The other thing I'd research is that via the Handle property you can get the hwnd (the Windows Handle). That might allow me to get into the browsers guts via PInvoke and get information in a different way. Don't know what's available, though. It doesn't sound easy either. – simon at rcl Jan 24 '14 at 15:02
  • Yeap, I was looking into overwriting the WndProc method. – sgrech Jan 24 '14 at 15:08
  • That's not a bad place to start, I guess. Bit hard core though! Have a read through Raymond Chens blog: http://blogs.msdn.com/b/oldnewthing/ - loads of good information (though not necessarily conveniently organised) and mostly very amusing. – simon at rcl Jan 24 '14 at 15:24
  • Thank you for your thoughts on my problem :) Much appreciated – sgrech Jan 24 '14 at 15:46
  • This looks useful: http://stackoverflow.com/questions/4219526/html-render-with-inspect-element-functionality-how-to-c-sharp – simon at rcl Jan 24 '14 at 16:22
  • Hi, simon at rcl, just to let you know. I ended up adding a mouse hook to the application, and the mouse clicks / move / scroll are triggering without adding a timer. :) – sgrech Jan 29 '14 at 15:01

0 Answers0