Announcement

Collapse
No announcement yet.

Mainly for Lance re: print screen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mainly for Lance re: print screen

    Back in the stone-age when your BBS was in Florida and state of
    the art modems was 1200 baud, you gave me the key scan code to
    trap print screen. I can't remember what it is and I long ago
    lost the source. Presuming it still works, can you remember what
    it is? Thanks.


    ------------------
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

  • #2
    I think this is what you are looking for.

    I got it yonks ago from PB, could have been Lance ?

    SUB SNAPSHOT SHARED
    ' ===================
    DIM SNAP$(1:25)
    TEMP$ = "": ICPREV = IC: CLOSE #7 '' optional use FREEFILE

    FOR IC = 1 TO 25
    FOR ID = 1 TO 80
    TEMP$ = TEMP$ + CHR$(SCREEN(IC,ID))
    NEXT ID
    SNAP$(IC)=TEMP$
    TEMP$ = ""
    NEXT IC

    OPEN "LPT1:" FOR OUTPUT AS #7 '' or whatever destination
    WIDTH "LPT1:", 80 '' you want to print to.

    TEMP$ = ""

    PRINT #7, CHR$(27) "@" ; '' Reset Printer
    FOR IC = 1 TO 11: PRINT #7, : NEXT IC
    FOR IC = 1 TO 25
    PRINT #7, SNAP$(IC) ;
    NEXT IC

    ERASE SNAP$
    PRINT #7, CHR$(12) ; '' Form Feed
    PRINT #7, CHR$(27) "@" ; '' Tidy up Printer

    CLOSE #7
    CLOSE #7
    IC = ICPREV: ICPREV = 0
    END SUB


    ------------------

    Comment


    • #3
      Enter PB/DOS and press <F1> to get online help. See "Keyboard Scan Codes".

      ------------------
      Tom Hanlin
      PowerBASIC Staff

      Comment


      • #4
        Not exactly Otto. What I want is to trap PrintScreen to prevent
        a screen dump to the printer.

        Tom, I tried the help files with no luck. The syntax, as I
        remember it is:

        On Key (x,y) gosub somewhere
        key x,y on

        However, PB hiccups on the "on key" statement. Apparently, it
        expects only one number within a certain range. Now I know this
        will work because I did it before, but.....



        ------------------
        There are no atheists in a fox hole or the morning of a math test.
        If my flag offends you, I'll help you pack.

        Comment


        • #5
          See the docs on the KEY statement. You need to define a trap key using the KEY n, CHR$(shiftstatus, scancode) syntax.

          ------------------
          Tom Hanlin
          PowerBASIC Staff

          Comment


          • #6
            The "unshifted" code is 55, as shown in the Scan Codes table in the help file.

            Note that under Windows, you have to disable "PrtSc" in the MISC tab of the shortcut Properties for the DOS app or else Windows does not pass the code to the application.
            Code:
            KEY 15, CHR$(0,55)
            ON KEY(15) GOSUB PrintScreen
            KEY(15) ON
             
            ...
             
            PrintScreen:
            BEEP
            RETURN

            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment


            • #7
              And the light over my head goes on!!!
              Thanks a lot Lance.


              ------------------
              There are no atheists in a fox hole or the morning of a math test.
              If my flag offends you, I'll help you pack.

              Comment

              Working...
              X