Saving images through a script

I have a script that compares images based on a template. Now depending on the version of the software being run a different numbers may be produced. When this happens I flag the fact that they are different, but I would like to capture the same image location.

How would I save this version automatically? Say there are 50 images on the screen. I would like to capture the ones that are different. I know I can get to the image location using image location, but how would I actually save this image?

Comments

  • Oh and I should add that I would like the saved images to be tolerant images as well. That is my default setting for image captures.
  • You can recapture an image based upon the original capture location if you add the size of that image to the original capture coordinates. This will create a rectangle that you can use to capture a new image via the CaptureScreen command.

    CaptureImageLocation.script
    params imageName, newName
    
    Put ImageInfo(ImageName) into info
    Put info.CaptureLocation into first          -- original capture coordinates
    Put Info.ImageSize plus first into last    -- image size plus capture coord
    
    // replace previous search type with tolerant
    put (SearchType:"Tolerant") into captureInfo
    add properties of info to captureInfo
    
    put item 1 to -2 delimited by "/" of info.imageName into path
    put path & "/" & newName into location
    
    // perform image capture 
    CaptureScreen (Name: location, Rect: (first, last), ImageInfo:captureInfo)
    

    You can use this script with:
    CaptureImageLocation "originalImageName", "newName"
    

    I should also mention that this method of recapturing images based upon the original image capture location can be a little risky. There is no guarantee that the new image on the screen will appear in the same location where the original image was previously captured. Therefore, the code above will ONLY work if the new images are located at the exact screen coordinates where the original image was captured.
  • Hmm.. ok. Let me try what you have suggested.

    I am keeping a tight leash on where I expect the image to show up. So, I do not expect too many problems with the new image, still I will check the image out.

    Thanks,
    Bharath
Sign In or Register to comment.