Search code examples
c#eventsbrowserwatin

catch user activity within webbrowser or watin


Is there any way to detect all the possible user activities within a WebBrowser and return a custom Event? For example: User clicks on "search" button, return "SearchButtonClicked" custom Event.

It would be something like, logging of all the activity that user does, stored in a sequence and could be automated once he wanted.

Edit: I do not own the webpage. I am trying to make an application to automate some searching on google.


Solution

  • After some research, I discovered the HtmlElementEventHandler.

    Example:

    webBrowser1.Document.GetElementById("MainContent_LoginButton").Click += new HtmlElementEventHandler(test);
    
    // some code...
    
    public void test(object sender, HtmlElementEventArgs e)
    {
        MessageBox.Show("Clicked login button");
    }