Python Forum
How we can prevent screen recording
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How we can prevent screen recording
#1
Smile 
After searching for hours, I have no choice left to ask some python gurus. I want to prevent a user to capture my app window.

I'm currently using tinker. I'm also aware of the C# but I want to do it in python.

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

Please note I'm currently new to python.
Reply
#2
No matter what you do, you can always record the HDMI signal, and you can get the devices for 4K under 50 €.

I know there is a way to block screen recording in general on Windows. A friend told me this. But he found another way to easily record it.
murad_ali likes this post
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#3
The reason for making a screen region black in screenshots or video recorder, is that I want to give hard time to non technical people. So, the videos on my app can't be recorded.

And I'm still shocked that we can record HDMI signal even if blocked the screen region?

I know how to make it black in C#, but I want it to do it in python!

As far now I found we use tinker.Frame().winfo_id() to get Window Handle then further we can use ctypes.

And I'm new to python and ctypes looks way much advanced to me.

Can you help me adding flex to that windows handle? Your hints will help me alot.
Reply
#4
You can try this, but renaming the name of the application breaks it.

from tkinter import Tk, Label, Button
from tkinter.messagebox import showwarning

# pip install psutil
from psutil import process_iter


def recording_observer(root):
    forbidden = ["obs.exe", "obs64.exe"]
    
    for process in process_iter():
        if process.name() in forbidden:
            root.withdraw()
            showwarning("Recoding", "Recording is not allowed")
            break
    else:
        root.deiconify()

    root.after(1_000, lambda: recording_observer(root))


root = Tk()
Label(root, text="Hello World").pack()
Button(root, text="Close", command=root.destroy).pack()

recording_observer(root)

root.mainloop()
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Using SQLAlchemy, prevent SQLite3 table update by multiple program instances Calab 3 703 Aug-09-2023, 05:51 PM
Last Post: Calab
  Video recording with Raspberry Pi - What´s wrong with my python code? Montezuma1502 3 1,180 Feb-24-2023, 06:14 PM
Last Post: deanhystad
  How to prevent python from going to new line in for loop? idknuttin 3 4,841 Feb-11-2022, 05:40 AM
Last Post: deanhystad
  How to decrease latency while recording streaming video. unicorn2019 0 1,232 Nov-15-2021, 02:12 PM
Last Post: unicorn2019
  Help with storing temp data for each day then recording min/max in app. trthskr4 3 2,356 Sep-10-2021, 10:51 PM
Last Post: trthskr4
  Split recording with Picamera EvanS1 0 1,881 Jun-19-2021, 12:26 PM
Last Post: EvanS1
  Prevent urllib.request from using my local proxy spacedog 0 2,803 Apr-24-2021, 08:55 PM
Last Post: spacedog
  Using pyaudio to stop recording under certain sound threshold Twanski94 2 6,301 Jun-13-2020, 11:35 AM
Last Post: Twanski94
  Prevent a PDF from being edited using Python? PythonNPC 1 2,232 May-05-2020, 09:04 PM
Last Post: micseydel
  recording a translation table into a file arbiel 0 1,421 Mar-31-2020, 02:33 PM
Last Post: arbiel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020