0

After searching for hours, I have no choice left to ask some python gurus. I want to prevent a user to capture my app windows, that is built in python.

I'm currently using tinker. I'm also aware of the C# but I want to do it in python. Here is a reference of C# How can i prevent screen recording using C#.

I hope there will be SetwindowDisplayAffinity alternative in python. Your reply will be appreciated.

Please note I'm currently new to python.

Murad Ali
  • 347
  • 2
  • 15

1 Answers1

0

SetwindowDisplayAffinity is a WinAPI function :

BOOL SetWindowDisplayAffinity(
  [in] HWND  hWnd, // A handle to the top-level window.
  [in] DWORD dwAffinity  /* The display affinity setting that specifies where 
                            the content of the window can be displayed.*/
);

The dwAffinity value you want is WDA_MONITOR (hex=0x00000001), so that part is not too difficult.
As for hWnd, the window handler, there is already answers for that : How to get the HWND of a Tkinter window on Windows? or Getting tkinter current window handle.
Now there's only to call that function : How to use Win32 API with Python?.
I'm not sure you will be able to call win32api.SetWindowDisplayAffinity after having pip installed pywin32, so in last resort you can use ctypes like in How to call a WINAPI function with ctypes and store the return value.

Lenormju
  • 4,078
  • 2
  • 8
  • 22