Screen Capture from FileMaker Pro on the Macintosh


Macintosh OS X has a built-in command line utility for taking screen captures. This utility can be called via AppleScript. FileMaker Pro can send out this command from a script. Why would you want to take screen captures using FileMaker Pro? I can think of two good reasons: building documentation within FileMaker Pro and for tech support enquiries from users of your solutions.

Apologies to Windows developers, I looked a bit, but couldn’t see an easy way to translate this into Windows. There are a number of command line utilities available, but I didn’t see a built-in one that I could harness. With a little imagination, you can probably make your favorite utility using the model employed here.

Basic Help files database

wpid3076-media_1359006640220.png

I built a simple database (Download FM-Screen-Capture.zip) consisting of two tables, Lessons and Lesson Steps. This is a very simplified version of the documentation software ScreenSteps. ScreenSteps has many more features, including the ability to markup screenshots with arrows, boxes, text, blurs etc. ScreenSteps is well worth a look for any FileMaker Pro developers who are serious about supporting their users. Sometimes, a developer just needs to have some simple documentation within their FileMaker Pro solution and the ability to do some quick screen grabs of their software is useful.

The Lesson Steps view

wpid3074-media_1359006684326.png

Screen captured in Lesson Step view

wpid3075-media_1359006706475.png

Screen captured into container field.

The script for Grabbing a Screenshot with screencapture

wpid3070-media_1359005883204.png

A Google search brought up this Macworld Hint article from 2003, which details how to use Macintosh OS X’s built-in screencapture utility via AppleScript. FileMaker Pro of course can run Applescripts from its own scripts.

This is a two-step script:

  1. perform a simple AppleScript to call screencapture do shell script “screencapture -i -c”
  2. paste the clipboard result into a container field.

Setting the options for capturing screenshots

wpid3071-media_1359005939852.png

There are a few options with the screencapture utility.

-i sets the cursor to interactive mode, basically a set of crosshairs that the user can click and drag over a screen to capture just a portion of the screen. If instead, the desire is to capture full windows each time, employ the -w option. -c sends the screen capture to the clipboard. Once in the clipboard, the next FileMaker Pro script step is to paste the contents of the clipboard into a container field.

#http://hints.macworld.com/article.php?story=2003031612560546
Perform AppleScript [ Native AppleScript:

— -i sets the cursor to ‘interactive mode’ and -c sends the screen capture to the clipboard. do shell script “screencapture -i -c”]

Paste [ Lesson_Steps::Step Image ] [ Select ]

 

Using screen captures in conjunction with User Help inquiries

wpid3072-media_1359005955149.png
media_1359313522466.png

This slightly longer script will capture a screenshot of the users entire screen and email it to a specified admin account. This script might be used in conjunction with generating a help inquiry to a system administrator. By generating an email via E-mail Client, with the ‘Perform without dialog’ option turned off, the user can see what is being sent and add any comments to the query.

The Help Screen Capture script

media_1359314548369.png

#Clear out script global fields.
Set Field [ Lessons::Help Notes Field; "" ]
Set Field [ Lessons::Help Screenshot Holder; "" ]

#Query the user for input about his issue.
Show Custom Dialog [ Title: “Help Request”; Message: “This script will take a screenshot of your entire screen and paste it into a Help request email. The screenshot will help your tech support person identify your issue. Please enter a description of your issue in the Notes field below. “; Buttons: “OK”, “Cancel”; Input #1: Lessons::Help Notes Field, “Notes:” ]

If [ Get(LastMessageChoice)=1 ]

#Commit the record and Adjust the Window to full screen to hide other user windows that may be open.
Commit Records/Requests [ Skip data entry validation; No dialog ]
Adjust Window [ Maximize ]

#Run screenshot AppleScript.
Perform AppleScript [ Native AppleScript: — -c sends the screenshot to the clipboard, -x does it silently. do shell script “screencapture -c -x” ]

#Paste screenshot into Global Container field. Note that the container field must be on the layout for the script to work. You could also open a separate window with the field on it.
Paste [ Lessons::Help Screenshot Holder ] [ Select ]

#Export the contents of the Global container field.
Set Variable [ $TempPath; Value:Get(TemporaryPath) ]
Set Variable [ $FileName; Value:Year(Get(CurrentDate))&”-“&Month(Get(CurrentDate))&”-“&Day(Get(CurrentDate))&”-screenshot.jpg” ]

#Send the screenshot and user notes to a support person.
Export Field Contents [ Lessons::Help Screenshot Holder; “$TempPath/$FileName” ]
Send Mail [ Send via E-mail Client; To: “info@hbase.net”; Subject: $FileName; Message: Lessons::Help Notes Field; Attachment: “$TempPath/$FileName” ]

#Adjust the window back to the proper size.
Adjust Window [ Resize to Fit ]

End If

Setting the options for screencapture

wpid3073-media_1359005969543.png

This time, the options are to send the screenshot directly to the clipboard -c and perform this task silently -x. By leaving out the options -i and -w, the entire screen is captured.

do shell script “screencapture -c -x”

5 Responses to “Screen Capture from FileMaker Pro on the Macintosh”

  1. Douglas…that is very cool indeed. Nice technique and nice post. Stephen

  2. Nice.

    Is there a way to specify screen coordinates or, perhaps, a specific field?

    • If you look in the script in the demo, you will see that you can specify which field the screenshot goes into. With regards to specifying specific screen coordinates, going back to the comments in the mentioned Macworld article, I see that the shell script has a few options, but I am not seeing a screen coordinates ability. You could launch in interactive mode and allow the user to select, or alternatively use the toggle for selecting just windows:

      usage: screencapture [-icmwsWx] [file] [cursor]
      -i capture screen interactively, by selection or window
      control key - causes screen shot to go to clipboard
      space key - toggle between mouse selection and
      window selection modes
      escape key - cancels interactive screen shot
      -c force screen capture to go to the clipboard
      -m only capture the main monitor, undefined if -i is set
      -w only allow window selection mode
      -s only allow mouse selection mode
      -W start interaction in window selection mode
      -x do not play sounds
      file where to save the screen capture

      You might also be able to script something more sophisticated by employing the Grab application, rather than the screen capture shell command.

Trackbacks/Pingbacks

  1. Screen Capture from FileMaker Pro on the Macintosh | Filemaker Info - January 28, 2013

    […] See on hbase.net […]

%d bloggers like this: