Draygoes Posted July 15, 2021 Share Posted July 15, 2021 "Ok, so what is it?" Just as it says in the title, you can choose to allow or disallow screenshots of your program. "But why?" You know that feeling when you first opened the CD tray with a line of code? Feels kind of like magic right? That's why I did this, it's a fun little magic trick that someone might find some real use for. "Weirdo." Hehe, I'm a bit tired right now. 😄 expandcollapse popup;WORKS AS OF VERSION 3.3.14.5 $WDA_NONE = 0x00000000;Imposes no restrictions on where the window can be displayed. $WDA_MONITOR = 0x00000001;The window content is displayed only on a monitor. Everywhere else, the window appears with no content or may not appear at all. Local $hGUI ;Usage - Just insert either function with no arguments any time after GUICreate. Func _preventscreenshot() DllCall("user32.dll", "BOOL", "SetWindowDisplayAffinity", "HWnd", $hGUI, "DWORD", $WDA_MONITOR) EndFunc Func _allowscreenshot() DllCall("user32.dll", "BOOL", "SetWindowDisplayAffinity", "HWnd", $hGUI, "DWORD", $WDA_NONE) EndFunc ;Example Use. It just calls the functions right after showing the GUI. The functions have no parameters. #include <GUIConstantsEx.au3> ; Create a GUI with various controls. Global $hGUI = GUICreate("Try to screenshot me!!!") _preventscreenshot() Local $idOK = GUICtrlCreateButton("Close", 310, 370, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox(64, "Screenshots are disabled.", "If you try to take a screenshot of the application window with this message open, the window will not appear in the screenshot. Clicking OK closes this dialog and ENABLES screenshotting.") _allowscreenshot() ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) canscreenshot.AU3 Spoiler "If a vegetarian eats vegetables,What the heck does a humanitarian eat?" "I hear voices in my head, but I ignore them and continue on killing." "You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring." An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist. Link to comment Share on other sites More sharing options...
TheXman Posted July 15, 2021 Share Posted July 15, 2021 (edited) Are you aware that the API call, with an example, already exists? Help File: _WinAPI_SetWindowDisplayAffinity Edited July 15, 2021 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Draygoes Posted July 15, 2021 Author Share Posted July 15, 2021 Oh, no I can't say that I was aware. I'm very new to the WinAPI side of things. Spoiler "If a vegetarian eats vegetables,What the heck does a humanitarian eat?" "I hear voices in my head, but I ignore them and continue on killing." "You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring." An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now