title: SendInput mouse time
body: <p>So basically what I'm trying to do is move my mouse smoothly to the center.
  What I have here works fine, but it teleports the cursor instantly to the center.</p>
  
  <p>Also if I set <code>input.mi.time</code> to a value larger than 0, it puts my PC to sleep. Can anyone explain a bit more on what it even does? The <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms646273.aspx" rel="nofollow noreferrer">documentation</a> didn't really clarify it for me.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;Windows.h&gt;
  
  int screenWidth;
  int screenHeight;
  
  void moveMouse(int x, int y)
  {
      POINT mouseCoords;
      GetCursorPos(&amp;mouseCoords);
  
      INPUT input;
      input.type = INPUT_MOUSE;
      input.mi.dwFlags = MOUSEEVENTF_MOVE;
      input.mi.dwExtraInfo = NULL;
      input.mi.mouseData = NULL;
      input.mi.dx = -mouseCoords.x + x;
      input.mi.dy = -mouseCoords.y + y;
      input.mi.time = NULL;
  
      SendInput(1, &amp;input, sizeof(INPUT));
  }
  
  void main()
  {
      screenWidth = GetSystemMetrics(SM_CXSCREEN);
      screenHeight = GetSystemMetrics(SM_CYSCREEN);
      int middleOfScreenX = screenWidth / 2;
      int middleOfScreenY = screenHeight / 2;
  
      moveMouse(middleOfScreenX, middleOfScreenY);
  }
  </code></pre>