Here is a neat little utility written in VB 6.0 that prints the contents of your screen to your default Windows printer. Can be very handy during debug, troubleshooting, or training. You can add a shortcut on your Quick Launch toolbar for an instant hardcopy of the current screen.


Option Explicit
' note: this is reformatted for blog viewing;
'   should be no line breaks in this statement
Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte,
  ByVal bScan As Byte,
  ByVal dwFlags As Long,
  ByVal dwExtraInfo As Long)

Sub Main()
  Clipboard.Clear
  '
  keybd_event vbKeySnapshot, 0, 0, 0
  DoEvents
  '
  keybd_event vbKeySnapshot, 0, &H2, 0
  DoEvents
  '
  Printer.Orientation = vbPRORLandscape
  If Clipboard.GetFormat(vbCFText) Then
    Printer.Print Clipboard.GetText()
    Printer.EndDoc
  End If
  If Clipboard.GetFormat(vbCFBitmap) Then
    Printer.PaintPicture Clipboard.GetData(), 0, 0
    Printer.EndDoc
  End If
End Sub