title: How can I count number of clicks anywhere on screen in C#?
body: <p>I am trying to have a C# program running in the background on Windows that will print "Hello!" after seeing that the user has clicked his or her mouse 10 times. But not just in the console window, anywhere on the screen.</p>
  
  <p>The following event handler for click-tracking is from msdn.microsoft.com:</p>
  
  <pre><code>private void OnMouseDownClickCount(object sender, MouseButtonEventArgs e) {
      // Checks the number of clicks.
      if (e.ClickCount == 1) {
          // Single Click occurred.
          lblClickCount.Content = "Single Click";
      }
      if (e.ClickCount == 2) {
          // Double Click occurred.
          lblClickCount.Content = "Double Click";
      }
      if (e.ClickCount &gt;= 3) {
          // Triple Click occurred.
          lblClickCount.Content = "Triple Click";
      }
  }
  </code></pre>
  
  <p>But, I'm not sure how to actually <em>use</em> this. When I add this function anywhere, the <code>MouseButtonEventArgs</code> type is undefined.</p>
  
  <p>What "using" statements do I need? How do I actually get this code to run properly -- do I call it once from <code>main</code>? What do I do to call it?</p>
  
  <p><strong>EDIT</strong>: Here is a picture showing Visual Studio not understanding MouseButtonEventArgs:</p>
  
  <p><a href="https://i.stack.imgur.com/zWGUC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zWGUC.png" alt="enter image description here"></a></p>