How to disable the "PRINT SCREEN" button while starting my application in WPF?

How to disable the print screen function while my WPF application is running?

A practical example: my client wants to avoid unnecessarily replicating valuable patient-oriented data from the outside world and they provide physical security so that people cannot receive data using non-digital means.

+7
c # wpf
source share
8 answers

It is impossible to turn off printing, and even if it were possible, it would be easy to bypass the cell phone camera. Many of them are in the resolution range of megapixels, which makes it quite simple to obtain the required information.

If you want to disable the Print Screen key on your keyboard, Jodrell's answer provides a way to do this (realizing that this will not make people type, and a specific user will find a way around this.)

In fact, it all comes down to trust. If an employer cannot trust its employees not to delete data that is already protected by law in most jurisdictions (HIPAA in the USA), then a bigger problem is at stake.

+4
source share

Well, perhaps, and it can really be useful if your application is deployed in an environment where the camera is not accessible to the user.

First of all, I used the RegisterHotKey and UnregisterHotKey API calls described here http://pinvoke.net/default.aspx/user32.RegisterHotKey , as described in this pretty old article here http://msdn.microsoft.com/en-us /magazine/cc163713.aspx .

I registered the IDHOT_SNAPDESKTOP in the IDHOT_SNAPDESKTOP event and did not register it in Window_Closed . Trying to do this in the constructor gave me problems getting a consistent handle using the WindowInteropHelper(this) method.

If you want to do more than just ignore the keys, you can customize the Windows message handler by pretending to use WndProc.

 HwndSource source = HwndSource.FromHwnd(<handle>); source.AddHook(<WndProc>); 

creating a descriptor as described above, and implementing WndProc yourself.

So far I do not know how to "not" process the hotkey and get windows for normal behavior, except, of course, unregistering the hot keys.

Its not very elegant or "WPF", but it worked for me.


Like @ghord comments

Using EnsureHandle() seems useful for getting a handler in a constructor.

+5
source share

Easy:

 Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().IsScreenCaptureEnabled = false; 
+1
source share

Simply put, you cannot. The "Print Screen" simply copies the pixels on the screen to the clipboard and is not part of your application.

0
source share

The only way I can think of is to use the native Windows API (SetWindowsHookEx) to catch all keystrokes and filter out the PrintScreen key. However, this will be associated with creating your own (i.e., unmanaged) DLL for the actual handling of keystrokes.

0
source share

Basically, you can hook into ClipBoard events and then set the image copied to null if someone does. Therefore, they can copy the image, but it will reset:

Look at this:

C # clipboard event

As an alternative to the timer, check the contents of the clip board and clear it as soon as it is installed on the image.

0
source share

No, there is no way to do this. Even if you close the print screen screen in your application, the user can adjust the focus to some other application, and then make the print screen (with your application on the side, etc.).

The only way would be to create a dummy application in the background that captures all keystrokes with the keyboard keys and filters the print screen, but this will happen for all applications, not just for you. And what's more, as George said, a user can use a cell phone camera too!

0
source share

I think the Microsoft Rights Management System can help. Give it a try. Below is the link:

Microsoft Rights Management System

0
source share

All Articles