"ImageCapture" function and/or capture images @ ru


A couple of questions:

  1. The help files I have about Eggplant/SenseTalk mention a function “imageCapture” but my version of Eggplant doesn’t recognize that command. Is there something special I need to do to enable it?

  2. I have a need to capture an image at runtime. Essentially, there’s going to be a popup window with some text on it (a day/time value) and I need to capture that day/time text and use it later. (It is not selectable text, so I can’t do any kind of ctrl-a, ctrl-c, copyremoteclipboard stuff).

I’m having trouble getting CaptureTextImage() to work (and also having trouble understanding it…it doesn’t create a new image in my .\Images folder…???) so I was thinking to capture a portion of the popup window, but I don’t know how to capture an image via script itself.

Any help is appreciated!


I’m not sure where the captureImage command went after v3.0 … however, the same feature should be available using the captureScreen command:

CaptureScreen Command
Example: CaptureScreen (Name: “ImageFileName”, Rectangle: ((67,33), imagelocation: “OtherCorner”)

Parameters: An optional property list.

Behavior: Captures a snapshot of the entire Viewer window, or a rectangle indicated in the property list. You can customize this command with a list of any number of the following properties:
[list]Name - An image file name and optional path information. (The default value is Capture_Screen.tiff, saved in the Results directory.)

Rectangle (or Rect) - A pair of diagonal locations indicating a rectangle to capture. (The locations can be screen coordinates, and/or image locations.)

Increment - A value of yes or true appends an automatically incremented number to the image. (The default value is no.)

ImageInfo - A property list of additional information. (For more information, see the ImageInfo() function.) [/list:u]
Tip: Incrementing is helpful if you are capturing several snapshots within a script (as in a loop or frequently called handler.) The images can all have the same image name, with the incremented number distinguishing them; otherwise, each image would overwrite the previous image with the same name.

Your last question hit a good point. You must have text-image caching turned on so you can access the image manually in the script’s TextImages folder for a comparison and to fully understand what its trying to match.

defaults write com.redstonesoftware.Eggplant TextCache -bool YES

Note: this is done in the Mac’s Terminal application, not in eggPlant :slight_smile:

From a practical standpoint, turning the cache on during script development is useful, and turning it off in production may be a good approach.

After a script is run, be aware that if a text image is not found, you cannot compare the image because it does not exist in the script’s results – unless you have caching turned on, at least in my experience.

Not sure which help files you are looking at, but the correct command for dynamically capturing images is CaptureScreen.

The captureTextImage command is only if you are implementing your own script based text-image generator (TIG). It’s what you call to tell Eggplant that the requested string has been rendered on screen and should be captured now.