title: Mouse drag window programmatically
body: <p>I'm trying to develop a program which will open 2 Guitar Pro files up and display them on different screens on my multiscreen setup.</p>
  
  <p>I have everything working except the moving of 1 window from screen 1 to screen 2.</p>
  
  <p>Guitar pro is a bit dodgy and for some reason will only open files in screen 1... I have tried to move the window by grabbing the window handle, but this only moves the main container and leaves all the child windows in place. I've decided to cheat it a bit and programmatically move the mouse cursor to click and drag the window from screen to screen, but am still running into issues...</p>
  
  <pre><code>[System.Runtime.InteropServices.DllImport("user32.dll")]
  static extern bool SetCursorPos(int x, int y);
  
  [System.Runtime.InteropServices.DllImport("user32.dll")]
  public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
  
  public void OpenFileFn()
      {
      Process file1 = new Process();
      file1.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
      file1.StartInfo.FileName = file;
      file1.Start();
      Thread.Sleep(500);
      Process file2 = new Process();
      file2.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
      file2.StartInfo.FileName = file;
      file2.Start();
      file2.WaitForInputIdle();
      Thread.Sleep(3000);
      int posX = Cursor.Position.X;
      int posY = Cursor.Position.Y;
      SetCursorPos(-960, 15);
      mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
      SetCursorPos(960, 15);
      mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
      SetCursorPos(posX, posY);
      }
  </code></pre>
  
  <p>Using the code above moves the cursor horizontally but not the window... If I change the cursor Y axis, the window moves vertically...</p>
  
  <p>Any ideas why how I can fix this?
  Thanks in advance...</p>