Skip to Content

Is there any way to direct the output from the "Print Screen" keyboard key directly to a printer?

Estimated Reading Time: 1 Minutes

The "PrintScreen" key is handled directly by the OS and cannot be referenced in COBOL.
However you can write an isCOBOL program that could be run as hotkey program.
For example, this setting in your properties file will run the program PRINTSCREEN when the F7 key (which returns the exception-value 7) is pressed:

   iscobol.hot_key.printscreen=7

You could also create a push-button in your GUI screen labeled "Print Screen" with an exception value (ex: 101) and associate that value to the hotkey variable:

   iscobol.hot_key.printscreen=101

The PRINTSCREEN program should call the "W$CAPTURE" routine.
There are examples of capturing the desktop and the current window in the SAMPLES program (%ISCOBOL%\sample\issamples) in the library routines section, as well as a simpler sample in the isCOBOL documentation for "W$CAPTURE".
In order to print the screen programmatically, you would choose the printer and print the image file using WIN$PRINTER, specifically the WINPRINT-SETUP and WINPRINT-PRINT-BITMAP op codes.
See the WIN$PRINTER sample also in the Library routines section of the SAMPLES program as well as the documentation on WINPRINT-PRINT_BITMAP.

Is there any way to direct the output from the "Print Screen" keyboard key directly to a printer?

Powered by PHPKB (Knowledge Base Software)