title: Simulating a click in the game window
body: <p>The problem is that I already have a working program that sends a click to an inactive window that is not on TOPLEVEL, but it does not work with all windows.
  And I cannot understand what is the reason for this behavior.
  When I filter messages with spy ++, they are exactly the same as with a real mouse click, but in the end the game does not respond.</p>
  <p>Initially, I coded it in python, but in the end it didn't work out for me and I decided to try C ++, despite the fact that I have no experience.
  Here's what I managed to put together in C ++.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;cstdlib&gt;
  #include &lt;windows.h&gt;
  #include &lt;winuser.h&gt;
  #include &lt;conio.h&gt;
  
  LPCTSTR WindowName = L&quot;Raid: Shadow Legends&quot;;
  HWND hMU = FindWindow(NULL, WindowName);
  int main() {
      if (hMU)
      {
          int x = 16; //selected values ​​based on the readings of spy ++
          int y = 266; //
          WINDOWPOS wp = { hMU, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE };
          
          SendMessage(hMU, WM_SETCURSOR, (WPARAM)hMU, MAKELPARAM(HTCLIENT, WM_MOUSEMOVE));
          SendMessage(hMU, WM_MOUSEACTIVATE, (WPARAM)hMU, MAKELPARAM(HTCLIENT, WM_LBUTTONDOWN));
          SendMessage(hMU, WM_WINDOWPOSCHANGING, 0, (LPARAM)&amp; wp);
          SendMessage(hMU, WM_NCPAINT, 1, 0);
          SendMessage(hMU, WM_WINDOWPOSCHANGED, 0, (LPARAM)&amp; wp);
          SendMessage(hMU, WM_ACTIVATEAPP, 1, 0);
          SendMessage(hMU, WM_NCACTIVATE, 1, 0);
          SendMessage(hMU, WM_ACTIVATE, WA_CLICKACTIVE, 0);
          SendMessage(hMU, WM_SETFOCUS, 0, 0);
          SendMessage(hMU, WM_SETCURSOR, (WPARAM)hMU, MAKELPARAM(HTCLIENT, WM_LBUTTONDOWN));
          PostMessage(hMU, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
          PostMessage(hMU, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(x, y));
          SendMessage(hMU, WM_CAPTURECHANGED, 0, 0);
      }
  }
  </code></pre>
  <p>The code is probably redundant or even bad, but I don't pay attention to it. I followed the path of exact copying of messages on mouse click. Sorry for this.
  I will accept any help. Also a Python solution would be nice.</p>