Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SetWindowDisplayAffinity - Protect window from screenshots/Software capture ?
#1
Hi !

Today at work i received a "Protected mail" in my outlook mailbox. It turns out that you can't take a screenshot of this type of e-mail, as it appears blacked out on the screenshot !

Intrigued, I searched a bit and found these functions :

SetWindowDisplayAffinity ( https://docs.microsoft.com/fr-fr/windows...dfrom=MSDN )
GetWindowDisplayAffinity (  https://docs.microsoft.com/en-us/windows...ayaffinity  )

I tried to "Import" them in QM, looking at how it's done in WinConstants & WinFunctions, but the function always returns me 0

Am i missing something or maybe this function would not work for what i want ?

Thanks in advance !

Macro Macro9
Code:
Copy      Help
dll user32
,#SetWindowDisplayAffinity hWnd dwFlags
,#GetWindowDisplayAffinity hWnd pdwAffinity

def WDA_NONE 0x00000000
def WDA_MONITOR 0x00000001
def WDA_EXCLUDEFROMCAPTURE 0x00000011


int w=win("Notepad")
_i=SetWindowDisplayAffinity(w WDA_EXCLUDEFROMCAPTURE)
out _i
#2
It only works if the window belongs to the current process

from MSDNParameters 
Code:
Copy      Help
[in] hWnd
Type: HWND
A handle to the top-level window. The window must belong to the current process.

this will work as dialog belongs to same process

Function DialogExample
Code:
Copy      Help
dll user32
,#SetWindowDisplayAffinity hWnd dwFlags
,#GetWindowDisplayAffinity hWnd pdwAffinity
def WDA_NONE 0x00000000
def WDA_MONITOR 0x00000001
def WDA_EXCLUDEFROMCAPTURE 0x00000011

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Static 0x54000000 0x0 72 0 48 12 "Test"
;4 Edit 0x54030080 0x200 64 36 96 13 ""
;5 Edit 0x54030080 0x200 64 64 96 12 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C00 "*" "" "" ""

str controls = "4 5"
str e4 e5
e4="test1"
e5="test2"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SetWindowDisplayAffinity(hDlg WDA_EXCLUDEFROMCAPTURE)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#3
It work, thanks ! I thought it would work on other windows but i didn't saw that it must be in the same process as the window, but i guess it's better than nothing :p


Forum Jump:


Users browsing this thread: 5 Guest(s)