No announcement yet.

Preventing PrtSc

  • Filter
  • Time
  • Show
Clear All
new posts

  • Preventing PrtSc

    I have a simple Information screen that randomly pops up and annoys a fellow employee.
    It is only displayed for about 1.5 seconds, and supplies information to concern the employee about
    a possible virus that has corrupted all the Games on this employees computer and warns them not
    to play them otherwise it will infect the rest of the office computers.

    The program is hidden from the task bar and task list. And is launched by the Startup folder.
    I would like also to prevent these employees from doing a screen capture to the clipboard.
    So they can't read it all at once.

    Is there a simple way to do this?


    -Keyboard trap ?
    -put a lock on the clipboard ?
    -monitor the clipboard and delete it if contains my Info screen ?
    -other ?

    Any suggestions are appreciated.

    Regards, Jules

    Best regards

  • #2
    Jules --
    Sure, that it possible to prevent Print Screen under NT, using SetWindowsHookEx with WH_KEYBOARD_LL (similar Ctrl-Alt-Del, Alt-Tab). But not under Windows 9x: to refuse from WH_KEYBOARD, I think, is too late, because OS already registered PrtSc as hotkey.
    So, suggestion is - establish simple global keyboard hook (you can find my samples in Source code forum), detect Print Screen, and then clean clipboard (probably, it's necessary to delay, using PostMessage or timer)
    Another stupid idea. OpenClipboard 0, display & hide information, and after this only execute CloseClipboard.
    Just now I'm in Windows95 and here this idea works.

    [This message has been edited by Semen Matusovski (edited June 05, 2000).]


    • #3
      Thanks Semen,

      I'll give that a try. OpenClipboard/CloseClipboard.

      Regards, Jules
      Best regards


      • #4
        Jules --

        It would be a good idea to open the clipboard, get its contents, display your screen, remove the screen, then restore the contents of the clipboard. That way your program won't interfere with the normal use of the clipboard.

        I would not recommend using a keyboard hook, for the same reasons that the WIN32.HLP file gives. They can impose a significant amount of overhead.

        -- Eric

        Perfect Sync: Perfect Sync Development Tools
        Email: mailto:[email protected][email protected]</A>

        [This message has been edited by Eric Pearson (edited June 05, 2000).]
        "Not my circus, not my monkeys."


        • #5
          Eric, thanks for the tip.

          If another program does open the clipboard and keeps it open while I try to get hold of it
          then it should not allow a PrtSc of my window or for that matter anybody.

          Would this be a correct assumption?

          Regards, Jules

          Best regards


          • #6
            I don't know. The PrintScreen key is handled by Windows, so I suppose it's possible that it works even when the Clipboard is open. You'd have to try it on 95, 98, NT, and 2000 to be sure.

            Fortunately most apps are "polite" enough to open the clipboard, use it, then close it. But with games, you never know what they are going to do.

            -- Eric

            Perfect Sync: Perfect Sync Development Tools
            Email: mailto:[email protected][email protected]</A>

            "Not my circus, not my monkeys."


            • #7
              jules --
              today i decided to test an idea of hotkey to detect prtsc.
              it works, at least, under 95b and nt4, but almost sure that everywhere.
              hotkey is less "expensive" than global hook and, i think, it's better to registrate it before displaying screen and then unregistrate.

              <font face="courier new, courier" size="3"><pre>
              #compile exe "hotkey.exe"
              #register none
              #dim all
              #include ""
              %id_text = 201
              callback function dlgproc
              static natom as dword
              select case cbmsg
              case %wm_initdialog
              natom = globaladdatom ("my hotkey" + str$(timer))
              registerhotkey cbhndl, natom, 0, %vk_snapshot
              settimer cbhndl, 1, 5000, byval 0
              case %wm_destroy
              unregisterhotkey cbhndl, natom
              globaldeleteatom natom
              case %wm_hotkey ' cbwparam = natom
              showwindow cbhndl, 1
              settimer cbhndl, 1, 3000, byval 0
              control set text cbhndl, %id_text, "prtsc pressed at " + time$
              case %wm_timer
              killtimer cbhndl, 1: showwindow cbhndl, 0
              end select
              end function
              function pbmain
              local hdlg as long
              dialog new 0, "hotkey (print screen)",,, 300, 40, %ws_sysmenu, _
              %ws_ex_topmost or %ws_ex_toolwindow to hdlg
              control add label, hdlg, %id_text, "press print screen in another apps or close this dialog", _
              5, 10, 290, 15, %ss_center
              dialog show modal hdlg call dlgproc
              end function

              ps. if you decided to struggle with developers, you have no chance to win -- there are enough simple ways to capture screen without print screen.
              imagine combination of hotkey and something like

              [this message has been edited by semen matusovski (edited june 06, 2000).]


              • #8
                Thanks for the code you supplied!

                Regards, Jules

                [This message has been edited by Jules Marchildon (edited June 09, 2000).]
                Best regards