Is there any way to block PrintScreen key using C++ code in linux? I am writing a C++ program which do not want user get screen shoot. I tried g_signal_connect to block PrintScreen key but it seems even not fire.
Why would you want to prevent the print screen key from working?!
Anyway, on Linux at least, this is impossible: when the print screen key is pressed, the window manager launches a little programme which captures the focussed X window (or the entire desktop or whatever) and writes it out as a PNG -- this happens outside your app, and unless you're in control of the entire desktop session, there's really no way to stop it.
If you really wanted to, you could try installing a hook that notices when print screen has been pressed and instantly blanks your window (and race the snapshot utility), though that is so easily worked around it seems pointless.
For example, the user could just configure the capture shortcut to something else, or run gnome-screenshot manually from the terminal. And even if you did get it working, how do you avoid someone pulling out their mobile phone and taking a picture of the monitor?
© 2022 - 2024 — McMap. All rights reserved.