It's hard to make a big package for such a task )) Attached to the message. The code is provided as is, without guarantees, authorship, limitations, etc. ...
I tested on Windows 8.1, which uses WDA_MONITOR instead of WDA_EXCLUDEFROMCAPTURE, so only the contents are hidden in the attached screenshot, not the entire window.
Instead of changing the signature "ON"/"OFF", I allowed myself to simply mark the menu command with a check box. It will be displayed instead of the icon.
And just as a joke, I shortened the code of your function to two lines )) Of course, you can return the original or write a new one. Especially since they are not quite equivalent when GetWindowDisplayAffinity returns false.
I will not bother with resource strings, I doubt you really need a translation. It is much more interesting to add a keyboard shortcut, if you want.
No reward required, thank you ))