add a screenshot button in a notes application or mailbox

IBM Notes and Domino: Tips & Tricks

Add a screenshot button in a Notes application or mailbox
October 27, 2014

By Lance Zakin, IBM CASA, CAAD
Notes and Domino
IBM BP NotesMail
A Domino developer might want to add a screenshot button in a Notes application or mailbox template if (1) Notes mailbox users have issues replying / forwarding to MIME HTML CSS emails, or (2) Notes app users have issues copy/pasting Notes app data to non-Notes mail client.

A Domino developer can use the LotusScript code below to implement, for example, a "Capture screenshot" button for end users.

Sub Click(Source As Button)
' Coded by NotesMail Consulting -
Const TITLE = "Capture screenshot"
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim result As Integer
Dim formula1 As Variant
Dim sysDrive, fileName, prog, msg As String
Dim Win64flag, choice As Boolean

Set db = session.CurrentDatabase
Set doc = New NotesDocument(db)
msg = "Press Alt-Print Screen (Alt-PrtSc) keys before clicking this button. After clicking button select & cut in Paint, then paste into email. Continue?" & Chr(13) & Chr(13) & _
"NOTE: Snipping Tool runs on Windows 7/Vista or higher. It will not auto-launch if running 64-bit Windows."

' Determine if Windows 64 or 32 bit; NOTE: LScript sesssion.Platform will always return Windosw/32 when running on Notes client
sysDrive = Environ("SystemDrive")
fileName = Dir(sysDrive & "\Program Files (x86)", 16)
Win64flag = False
' Notes client cannot auto-launch Snipping Tool on 64-bit Windows, so MSFT Paint will be launched instead
If fileName <> "" Then
Win64flag = True
choice = ws.Prompt (PROMPT_YESNO, TITLE, msg)
If Not choice Then Exit Sub
End If

' Determine Windows version; MSFT Snipping Tool installed on Windows Vista (6.0) and higher
formula1 = Evaluate(|@TextToNumber(@Subset(@Subset(@Platform([Specific]); -2); 1))|, doc)
If formula1(0) < 6 Or Win64flag Then prog = "mspaint.exe" Else prog = "snippingtool.exe"
' Support Windows XP: Snipping Tool is not installed, so MSFT Paint will be launched instead
If formula1(0) < 6 Then
choice = ws.Prompt (PROMPT_YESNO, TITLE, msg)
If Not choice Then Exit Sub
End If

result = Shell(prog, 1)
End Sub

Reference Sources

Microsoft Snipping Tool
Snipping Tool is a screenshooting utility included in Windows Vista and later. It can take screenshots of an open window, rectangular areas, a free-form area, or the entire screen. Snips can then be annotated using a mouse or a tablet, stored as an image file (PNG, GIF, or JPEG file) or an MHTML file, or e-mailed. Snipping Tool allows for basic image editing of the snapshot, with different colored pens, an eraser, and a highlighter.

Microsoft Paint
Paint (formerly Paintbrush for Windows) is a simple graphics painting program that has been included with all versions of Microsoft Windows. It is often referred to as MS Paint or Microsoft Paint. The program opens and saves files as Windows bitmap (24-bit, 256 color, 16 color, and monochrome, all with the .bmp extension), JPEG, GIF (without animation or transparency, although the Windows 98 version, a Windows 95 upgrade, and the Windows NT4 version did support the latter), PNG (without alpha channel), and TIFF (without multiple page support).