title: C++ move mouse in windows using SetCursorPos
body: <p>I created a device similar to a wiimote and i want to use it as a mouse in windows (8.1).
  The device connects over tcp to a c++ win32 program on my windows computer and sends the position where the mouse cursor should move. I am using the SetCursorPos function to set the position, which works great to control most programs. But when I try to control for example the task manager, the cursor doesn't move anymore. When I switch from the task manager back to some other program it works again. I also tried to use the SendInput function with the same results.</p>
  
  <p>This is what my code looks like with SendInput:</p>
  
  <pre><code>INPUT Input = { 0 };
  Input.type = INPUT_MOUSE;
  
  Input.mi.dx = (LONG)posX;
  Input.mi.dy = (LONG)posY;
  
  // set move cursor directly
  Input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
  
  SendInput(1, &amp;Input, sizeof(INPUT));
  </code></pre>
  
  <p>With SetCursorPos it's just one line:</p>
  
  <pre><code>SetCursorPos(posX, posY);
  </code></pre>
  
  <p>Can anybody tell me why it doesn't work for some programs? I know it has to be possible to do this, since I tried a smartphone app which controls the cursor and it worked in all programs.</p>