title: C++ mouse click on certain spot in window
body: <p>I have my function here working, but I am certainly going about it the wrong way.</p>
  
  <p>My program uses FindWindow to find the correct window. I need to double click on a specific location on this window. </p>
  
  <p>I made it work by always putting the window in the same location on the screen, but if I moved the window the program would try click on the hard-coded location I have provided and it would not work. </p>
  
  <p>Here is the function:</p>
  
  <pre><code>void lobbyWindow(HWND main_client)
  {
    //RECT arect;
  
     // GetWindowRect(main_client, &amp;arect); 
  
      SetCursorPos(748,294);
      mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
      mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
      mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
      mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
  
  }
  </code></pre>
  
  <p>As you can see I just move the mouse to 748,294 and double click. What I want to do is set the mouse to 100,100 in the main_client window, so if I move the main_client window the mouse still clicks on the correct spot.</p>