This can be complicated depending on the display mode of the game, if the game is in full screen mode unique means that it has priority over the screen and no other application will be able to display anything other than it, already in other modes like window or full screen window can-overlap in a very easy way.
Apps like Discord for example do this overlay "Overlay
name of the technique" directly in DirectX
, however if you are going to do this in online games with anti-hack protection very likely you will be detected since this to modify the game graphic in unauthorized mode.
As I said if the game is not in full screen mode you can use a API
Windows to override your window inside the game, ie your window will become daughter of the game window as one if it is modal.
Example and C#:
// API Windows
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
// Pega o processo - Jogo CS GO
Process hostProcess = Process.GetProcessesByName("csgo")[0];
// Pega o identificador da minha janela overlay janela Handle
IntPtr hostHandle = new WindowInteropHelper(this).Handle;
// Pega o identificador da janela do CS GO
IntPtr guestHandle = hostProcess.MainWindowHandle;
// Seta a janela filho......
SetParent(hostHandle, guestHandle);
I don’t use Python but the API
can be used with it normally, the parameters for it are the Handles
windows, to learn more -> https://www.pinvoke.net/default.aspx/user32.setparent.