title: SetCursorPos Not Working
body: <p>I'm using the following library: <a href="http://www.codeproject.com/Articles/28064/Global-Mouse-and-Keyboard-Library?fid=1518257&amp;df=90&amp;mpp=25&amp;noise=3&amp;prof=False&amp;sort=Position&amp;view=Quick&amp;fr=51#xx0xx" rel="noreferrer">http://www.codeproject.com/Articles/28064/Global-Mouse-and-Keyboard-Library?fid=1518257&amp;df=90&amp;mpp=25&amp;noise=3&amp;prof=False&amp;sort=Position&amp;view=Quick&amp;fr=51#xx0xx</a></p>
  
  <p>To help me work with low level mouse hooks in Windows 7. I create a timer to check the last time a mouse move event was fired, and if it's longer than a given time, I move the mouse to the top left corner of the screen using SetCursorPos(0,0)</p>
  
  <p>Before moving the mouse, I took it's old coordinates, and saved them. So that when I receive the next MouseMove event I can replace the mouse in it's original location. However, upon called SetCursorPos(oldPos.x, oldPos.y), the mouse does not move.</p>
  
  <p>I'm sure that the oldPos values are correct, however the cursor refuses to move. Could this be due to the library I'm using? Please help. </p>
  
  <pre><code>[DllImport("user32.dll", SetLastError = true)]
      public static extern bool SetCursorPos(int X, int Y);
          [DllImport("user32.dll")]
      public static extern bool GetCursorPos(out POINT lpPoint);
  void mouseHook_MouseMove(object sender, MouseEventArgs e)
      {
          //If the mouse was not visible, move it back to it's original position
          if (!mouseVisible)
          {
              mouseVisible = true;
  
              SetCursorPos(cursorPosition.x, cursorPosition.y);
          }
  
          //Update the last moved time.
          lastMoved = DateTime.Now;
      }
  
  private void hideMouse(object sender, EventArgs e)
      {
          if (mouseVisible &amp;&amp; (DateTime.Now - lastMoved) &gt; new TimeSpan(0, 0, 0, mouseControl.timeTrackBar.Value))
          {
              log.Debug("Hiding mouse.");
  
              //Store the current mouse position.
              GetCursorPos(out cursorPosition);
  
              //Hide the mouse.
              SetCursorPos(0, 0);
              log.Debug("Moving cursor to 0,0");
  
              mouseVisible = false;
          }
  </code></pre>