KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q26485: Trapping ALT+, SHIFT+, or CTRL+PRINT SCREEN, &H80 Key Flag

Article: Q26485
Product(s): See article
Version(s): 3.00 4.00 4.00b 4.50
Operating System(s): MS-DOS
Keyword(s): ENDUSER | B_GWBasicI | mspl13_basic
Last Modified: 23-MAY-1989

Problem:

I am unable to trap the PRINT SCREEN key (on an IBM extended
keyboard, such as on an IBM AT) when pressed simultaneously with the
ALT, SHIFT, or CTRL key. However, these can be trapped, with the
exception of CTRL+PRINT SCREEN, within the QuickBASIC editing
environment.

These keys can be trapped using GW-BASIC Interpreter Version 3.20. The
following is a code example:

KEY 15, CHR$(&H04) + CHR$(&H37)
KEY(15) ON
ON KEY(15) GOSUB keytrap
idle: GOTO idle
keytrap:
   PRINT "CONTROL+PRINT SCREEN key sequence trapped"
   RETURN

Response:

This problem results because the value &H80 is missing from the
keyboardflag argument of the KEY statement. You must add this value
whenever you trap the PRINT SCREEN key on an extended keyboard.
Therefore, the correct method for trapping the key is as follows:

KEY 15, CHR$(&H80 + &H04) + CHR$(&H37)
KEY(15) ON
ON KEY(15) GOSUB keytrapidle: GOTO idle
keytrap:
   PRINT "CONTROL+PRINT SCREEN key sequence trapped"
   RETURN

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.